feat: flake-compat

This commit is contained in:
Kat Inskip 2022-12-04 15:55:08 +01:00
parent ed581ca5b4
commit 419fcaa79f
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
5 changed files with 170 additions and 132 deletions

View file

@ -1,122 +1,7 @@
{ self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, arcexprs, ... }@inputs: let
tree = (inputs.tree.tree {
inherit inputs;
folder = ./.;
config = {
"/" = {
excludes = [
"flake"
"default"
];
};
"nixos/modules" = {
functor = {
enable = true;
external = with (import (arcexprs + "/modules")).nixos; [
base16
base16-shared
];
};
};
"home/modules" = {
functor = {
enable = true;
external = with (import (arcexprs + "/modules")).home-manager; [
base16
base16-shared
];
};
};
"home".evaluateDefault = true;
"home/*" = {
functor.enable = true;
};
};
}).impure;
lib = inputs.nixpkgs.lib;
inherit (lib.attrsets) mapAttrs;
inherit (lib.lists) singleton;
in utils.lib.mkFlake {
inherit self inputs;
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
channelsConfig.allowUnfree = true;
hostDefaults = {
system = "x86_64-linux";
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 inputs tree;
machine = name;
};
modules = [
({ config, ... }: {
home = {
username = "kat";
stateVersion = "22.11";
homeDirectory = "/home/kat";
};
})
path
];
}) tree.home;
inherit tree;
};
devShells = {
"python" = mach-nix.mkPythonShell {
python = "python310";
requirements = ''
'';
};
};
}
let
inputs = import ./inputs.nix;
self = import ./outputs.nix ({
inherit self inputs;
system = builtins.currentSystem;
} // inputs);
in self