Skip to content

Commit 7cb26cb

Browse files
authored
Merge pull request #23 from Kranzes/flake-parts-refactor
nix: refactor and start using flake-parts
2 parents e518219 + f18629c commit 7cb26cb

File tree

6 files changed

+76
-54
lines changed

6 files changed

+76
-54
lines changed

docs/default.nix

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/flake-module.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
perSystem = { pkgs, lib, ... }: {
3+
packages.docs = pkgs.runCommand "nixos-remote-docs"
4+
{
5+
passthru.serve = pkgs.writeShellScriptBin "serve" ''
6+
cd docs
7+
${lib.getExe pkgs.mdbook} serve --dest-dir $(${pkgs.coreutils}/bin/mktemp -d)
8+
'';
9+
}
10+
''
11+
cp -r ${lib.cleanSource ./.}/* .
12+
${lib.getExe pkgs.mdbook} build --dest-dir "$out"
13+
'';
14+
};
15+
}

flake.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,22 @@
11
{
22
description = "A universal nixos installer, just needs ssh access to the target system";
33

4-
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
5-
inputs.disko.url = "github:nix-community/disko/master";
6-
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
7-
# used for testing
8-
inputs.nixos-images.url = "github:nix-community/nixos-images";
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6+
flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; };
7+
disko = { url = "github:nix-community/disko/master"; inputs.nixpkgs.follows = "nixpkgs"; };
8+
# used for testing
9+
nixos-images.url = "github:nix-community/nixos-images";
10+
};
911

10-
outputs = { self, disko, nixpkgs, nixos-images, ... }:
11-
let
12-
supportedSystems = [
13-
"x86_64-linux"
14-
"i686-linux"
15-
"aarch64-linux"
16-
"x86_64-darwin"
17-
"aarch64-darwin"
12+
13+
outputs = inputs:
14+
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
15+
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
16+
imports = [
17+
./src/flake-module.nix
18+
./tests/flake-module.nix
19+
./docs/flake-module.nix
1820
];
19-
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
20-
in
21-
{
22-
packages = forAllSystems (system:
23-
let pkgs = nixpkgs.legacyPackages.${system}; in
24-
{
25-
default = self.packages.${system}.nixos-remote;
26-
docs = pkgs.callPackage ./docs { };
27-
nixos-remote = pkgs.callPackage ./src { };
28-
});
29-
checks.x86_64-linux =
30-
let
31-
pkgs = nixpkgs.legacyPackages.x86_64-linux;
32-
inputs = {
33-
inherit pkgs;
34-
inherit (disko.nixosModules) disko;
35-
nixos-remote = self.packages.x86_64-linux.nixos-remote;
36-
kexec-installer = "${nixos-images.packages.${pkgs.system}.kexec-installer-nixos-unstable}/nixos-kexec-installer-${pkgs.stdenv.hostPlatform.system}.tar.gz";
37-
};
38-
in
39-
{
40-
from-nixos = import ./tests/from-nixos.nix inputs;
41-
from-nixos-with-sudo = import ./tests/from-nixos-with-sudo.nix inputs;
42-
};
4321
};
4422
}

src/flake-module.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
perSystem = { pkgs, ... }: {
3+
packages = rec {
4+
nixos-remote = pkgs.callPackage ./. { };
5+
default = nixos-remote;
6+
};
7+
};
8+
}

tests/flake-module.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ withSystem, inputs, ... }:
2+
3+
{
4+
flake.checks.x86_64-linux = withSystem "x86_64-linux" ({ pkgs, system, inputs', config, ... }:
5+
let
6+
testInputs = {
7+
inherit pkgs;
8+
inherit (inputs.disko.nixosModules) disko;
9+
nixos-remote = config.packages.nixos-remote;
10+
kexec-installer = "${inputs'.nixos-images.packages.kexec-installer-nixos-unstable}/nixos-kexec-installer-${system}.tar.gz";
11+
};
12+
in
13+
{
14+
from-nixos = import ./from-nixos.nix testInputs;
15+
from-nixos-with-sudo = import ./from-nixos-with-sudo.nix testInputs;
16+
});
17+
}

0 commit comments

Comments
 (0)