feat: overengineered python devshell

This commit is contained in:
Kat Inskip 2022-12-04 18:33:41 +01:00
parent 573563c3d2
commit 269d3929f6
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
3 changed files with 108 additions and 83 deletions

View file

@ -35,87 +35,104 @@
};
}).impure;
lib = inputs.nixpkgs.lib;
inherit (lib.attrsets) mapAttrs;
in utils.lib.mkFlake {
inherit self inputs;
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
channelsConfig.allowUnfree = true;
inherit (lib.lists) fold;
inherit (lib.attrsets) mapAttrs recursiveUpdate;
recursiveMergeAttrs = listOfAttrsets: fold (attrset: acc: recursiveUpdate attrset acc) {} listOfAttrsets;
in recursiveMergeAttrs [
(utils.lib.mkFlake {
inherit self inputs;
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
channelsConfig.allowUnfree = true;
hostDefaults = {
system = "x86_64-linux";
modules = [
tree.system.modules
];
extraArgs = {
inherit inputs tree;
};
};
hosts = let
outputForSystem = system: {
"x86_64-linux" = "nixosConfigurations";
"aarch64-darwin" = "darwinConfigurations";
}.${system};
builderForSystem = system: {
"x86_64-linux" = nixpkgs.lib.nixosSystem;
"aarch64-darwin" = darwin.lib.darwinSystem;
}.${system};
modulesForSystem = system: {
"x86_64-linux" = [
home-manager.nixosModules.home-manager
ragenix.nixosModules.age
tree.nixos.modules
];
"aarch64-darwin" = [
home-manager.darwinModules.home-manager
ragenix.nixosModules.age
tree.darwin.modules
];
}.${system};
mapSystem = system: name: path: {
inherit system;
output = outputForSystem system;
builder = builderForSystem system;
modules = (modulesForSystem system) ++ [
path
];
extraArgs = {
machine = name;
};
};
in mapAttrs (mapSystem "x86_64-linux") tree.nixos.systems
// mapAttrs (mapSystem "aarch64-darwin") tree.darwin.systems;
outputsBuilder = channels: {
nixosConfigurations = mapAttrs(_: sys: sys.extendModules {
modules = [ scalpel.nixosModule ];
specialArgs = {
prev = sys;
};
}) self.nixosConfigurations;
homeManagerConfigurations = mapAttrs (name: path: home-manager.lib.homeManagerConfiguration {
pkgs = channels.nixpkgs;
extraSpecialArgs = {
inherit channels inputs tree;
machine = name;
nixos = {};
};
hostDefaults = {
system = "x86_64-linux";
modules = [
tree.system.modules
tree.home.common
path
];
}) tree.home.profiles;
inherit tree;
};
devShells = {
"python" = mach-nix.mkPythonShell {
python = "python310";
requirements = ''
'';
extraArgs = {
inherit inputs tree;
};
};
};
}
hosts = let
outputForSystem = system: {
"x86_64-linux" = "nixosConfigurations";
"aarch64-darwin" = "darwinConfigurations";
}.${system};
builderForSystem = system: {
"x86_64-linux" = nixpkgs.lib.nixosSystem;
"aarch64-darwin" = darwin.lib.darwinSystem;
}.${system};
modulesForSystem = system: {
"x86_64-linux" = [
home-manager.nixosModules.home-manager
ragenix.nixosModules.age
tree.nixos.modules
];
"aarch64-darwin" = [
home-manager.darwinModules.home-manager
ragenix.nixosModules.age
tree.darwin.modules
];
}.${system};
mapSystem = system: name: path: {
inherit system;
output = outputForSystem system;
builder = builderForSystem system;
modules = (modulesForSystem system) ++ [
path
];
extraArgs = {
machine = name;
};
};
in mapAttrs (mapSystem "x86_64-linux") tree.nixos.systems
// mapAttrs (mapSystem "aarch64-darwin") tree.darwin.systems;
outputsBuilder = channels: {
nixosConfigurations = mapAttrs(_: sys: sys.extendModules {
modules = [ scalpel.nixosModule ];
specialArgs = {
prev = sys;
};
}) self.nixosConfigurations;
homeManagerConfigurations = mapAttrs (name: path: home-manager.lib.homeManagerConfiguration {
pkgs = channels.nixpkgs;
extraSpecialArgs = {
inherit channels inputs tree;
machine = name;
nixos = {};
};
modules = [
tree.system.modules
tree.home.common
path
];
}) tree.home.profiles;
devShells = {
rust = with channels.nixpkgs; mkShell {
nativeBuildInputs = [
cargo
rustc
rustfmt
rustPackages.clippy
rust-analyzer
];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
};
inherit tree;
};
})
(utils.lib.eachDefaultSystem (system: {
devShells.python = nixpkgs.legacyPackages."${system}".mkShell {
buildInputs = let
pythonWithPkgs = mach-nix.lib."${system}".mkPython {
ignoreDataOutdated = true;
python = "python310";
}; in [ pythonWithPkgs ];
};
}))
]