Split flake into multiple files

This commit is contained in:
Pim Kunis 2024-11-11 21:40:36 +01:00
parent 47c2a10ee7
commit d70a737bc2
9 changed files with 159 additions and 108 deletions

15
checks.nix Normal file
View file

@ -0,0 +1,15 @@
{
self,
flake-utils,
git-hooks,
...
}:
flake-utils.lib.eachDefaultSystem (system: {
checks.pre-commit-check = git-hooks.lib.${system}.run {
src = ./.; # TODO: self?
hooks.treefmt = {
enable = true;
package = self.packages.${system}.formatter;
};
};
})

41
colmena.nix Normal file
View file

@ -0,0 +1,41 @@
inputs @ {
self,
nixpkgs,
...
}: {
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
};
specialArgs = {
inherit inputs self;
};
};
sue = {
deployment = {
allowLocalDeployment = true;
targetHost = null;
};
imports = [
(import ./machines).sue.module
./nixos
];
};
gamepc = {
deployment = {
targetHost = "gamepc";
targetUser = "root";
};
imports = [
(import ./machines).gamepc.module
./nixos
];
};
};
}

12
dev-shells.nix Normal file
View file

@ -0,0 +1,12 @@
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: {
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
};
})

View file

@ -256,6 +256,24 @@
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
@ -416,7 +434,7 @@
"crane": "crane",
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts",
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
@ -689,6 +707,7 @@
"root": {
"inputs": {
"disko": "disko",
"flake-utils": "flake-utils",
"git-hooks": "git-hooks",
"home-manager": "home-manager",
"lanzaboote": "lanzaboote",
@ -815,6 +834,21 @@
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_4"

114
flake.nix
View file

@ -8,6 +8,7 @@
stylix.url = "github:pizzapim/stylix/release-24.05";
treefmt-nix.url = "github:numtide/treefmt-nix";
nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
flake-utils.url = "github:numtide/flake-utils";
git-hooks = {
url = "github:cachix/git-hooks.nix";
@ -51,110 +52,13 @@
};
};
outputs = {
self,
nixpkgs,
...
} @ inputs: let
supportedSystems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
outputs = inputs @ {flake-utils, ...}:
flake-utils.lib.meld inputs [
./packages.nix
./formatter.nix
./nixos-configurations.nix
./checks.nix
./dev-shells.nix
./colmena.nix
];
forAllSystems' = nixpkgs.lib.genAttrs;
forAllSystems = forAllSystems' supportedSystems;
pkgsForSystem = system:
import nixpkgs {
inherit system;
};
treefmtEval = forAllSystems (
system: inputs.treefmt-nix.lib.evalModule (pkgsForSystem system) ./treefmt.nix
);
in {
formatter = forAllSystems (system: (treefmtEval.${system}.config.build.wrapper));
nixosConfigurations = nixpkgs.lib.mapAttrs (
name: nixosModule:
nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
inherit inputs system self;
};
modules = [
nixosModule
./nixos
];
}
) (import ./machines);
checks = forAllSystems (system: {
pre-commit-check = inputs.git-hooks.lib.${system}.run {
src = ./.;
hooks = {
treefmt = {
enable = true;
package = treefmtEval.${system}.config.build.wrapper;
};
};
};
});
devShells = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
};
});
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
};
specialArgs = {
inherit inputs self;
};
nodeSpecialArgs = {
sue = {};
};
};
sue = {
name,
nodes,
...
}: {
deployment = {
allowLocalDeployment = true;
targetHost = null;
};
imports = [
(import ./machines).sue
./nixos
];
};
gamepc = {
name,
nodes,
...
}: {
deployment = {
targetHost = "gamepc";
targetUser = "root";
};
imports = [
(import ./machines).gamepc
./nixos
];
};
};
};
}

8
formatter.nix Normal file
View file

@ -0,0 +1,8 @@
{
self,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: {
formatter = self.packages.${system}.formatter;
})

View file

@ -1,4 +1,11 @@
{
sue = import ./sue;
gamepc = import ./gamepc;
sue = {
system = "x86_64-linux";
module = import ./sue;
};
gamepc = {
system = "x86_64-linux";
module = import ./gamepc;
};
}

17
nixos-configurations.nix Normal file
View file

@ -0,0 +1,17 @@
inputs @ {
nixpkgs,
self,
...
}:
nixpkgs.lib.mapAttrs (name: {
system,
module,
}:
nixpkgs.lib.nixosSystem {
inherit system;
modules = [./nixos module];
specialArgs = {
inherit inputs system self;
};
}) (import ./machines)

13
packages.nix Normal file
View file

@ -0,0 +1,13 @@
{
nixpkgs,
flake-utils,
treefmt-nix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
treefmtWrapper = treefmtEval.config.build.wrapper;
in {
packages.formatter = treefmtWrapper;
})