Merge branch 'nixos' into nixos-work

This commit is contained in:
Moritz Böhme 2022-09-01 11:14:01 +02:00
commit da9ee28cdd
2 changed files with 20 additions and 4 deletions

View file

@ -7,19 +7,35 @@
with lib; with lib;
let let
cfg = config.my.programs.python; cfg = config.my.programs.python;
mkPython = packages: version: pkgs.${version}.withPackages (ps: map (flip getAttr ps) packages);
pythonVersions = [
"python311"
"python310"
"python39"
"python38"
];
packageLists = map (version: attrNames pkgs."${version}Packages") cfg.versions;
commonPackages = foldl' intersectLists (head packageLists) (tail packageLists);
in in
{ {
options.my.programs.python = { options.my.programs.python = {
enable = mkEnableOption "python"; enable = mkEnableOption "python";
versions = mkOption { versions = mkOption {
default = [ "python310" ]; default = [ "python310" ];
type = with types; listOf str; type = with types; nonEmptyListOf (enum pythonVersions);
example = [ "python39" ]; example = [ "python39" ];
apply = builtins.map (version: pkgs.${version}.withPackages (packages: with packages; [ black pyflakes isort nose pytest python-lsp-server ])); };
packages = mkOption {
default = [ "isort" "pytest" "flake8" "python-lsp-server" ];
type = with types; listOf (enum commonPackages);
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.home.packages = cfg.versions; users.users.moritz.packages = map (mkPython cfg.packages) cfg.versions;
}; };
} }

View file

@ -20,7 +20,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
virtualisation.libvirtd = { virtualisation.libvirtd = {
enable = true; enable = true;
package = pkgs.stable.libvirt; package = pkgs.libvirt;
}; };
home-manager.users.moritz.home.packages = with pkgs; [ virt-manager ]; home-manager.users.moritz.home.packages = with pkgs; [ virt-manager ];
users.users.moritz.extraGroups = [ "libvirtd" ]; users.users.moritz.extraGroups = [ "libvirtd" ];