-
-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathflake.nix
More file actions
138 lines (128 loc) · 4.65 KB
/
Copy pathflake.nix
File metadata and controls
138 lines (128 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
description = "Disko - declarative disk partitioning";
# FIXME: in future we don't want lock here to give precedence to a USB live-installer's registry,
# but garnix currently does not allow this.
#inputs.nixpkgs.url = "nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs, ... }:
let
lib = nixpkgs.lib;
supportedSystems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
"riscv64-linux"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs supportedSystems;
versionInfo = import ./version.nix;
version = versionInfo.version + (lib.optionalString (!versionInfo.released) "-dirty");
diskoLib = import ./lib {
inherit (nixpkgs) lib;
makeTest = import (nixpkgs + "/nixos/tests/make-test-python.nix");
eval-config = import (nixpkgs + "/nixos/lib/eval-config.nix");
qemu-common = import (nixpkgs + "/nixos/lib/qemu-common.nix");
};
in
{
nixosModules.default = self.nixosModules.disko; # convention
nixosModules.disko = ./module.nix;
flakeModule = self.flakeModules.default;
flakeModules.default = self.flakeModules.disko;
flakeModules.disko = ./flake-module.nix;
lib = diskoLib;
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
disko = pkgs.callPackage ./package.nix { diskoVersion = version; };
# alias to make `nix run` more convenient
disko-install = self.packages.${system}.disko.overrideAttrs (_old: {
name = "disko-install";
});
default = self.packages.${system}.disko;
create-release = pkgs.callPackage ./scripts/create-release.nix { };
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64) {
disko-doc = pkgs.callPackage ./doc.nix { };
}
);
# TODO: disable bios-related tests on aarch64...
# Run checks: nix flake check -L
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# FIXME: aarch64-linux seems to hang on boot
nixosTests = lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 (
import ./tests {
inherit pkgs;
makeTest = import (nixpkgs + "/nixos/tests/make-test-python.nix");
eval-config = import (nixpkgs + "/nixos/lib/eval-config.nix");
qemu-common = import (nixpkgs + "/nixos/lib/qemu-common.nix");
}
);
disko-install = pkgs.callPackage ./tests/disko-install {
inherit self;
diskoVersion = version;
};
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/zfs-swap-deactivate.jq}
touch $out
'';
jsonTypes = pkgs.writeTextFile {
name = "jsonTypes";
text = (builtins.toJSON diskoLib.jsonTypes);
};
treefmt = pkgs.runCommand "treefmt" { } ''
${self.formatter.${system}}/bin/treefmt --ci --working-dir ${self}
touch $out
'';
in
# FIXME: aarch64-linux seems to hang on boot
lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 (nixosTests // { inherit disko-install; })
//
pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64 && !pkgs.stdenv.hostPlatform.isx86_32)
{
inherit jsonTypes treefmt checkJqSyntax;
inherit (self.packages.${system}) disko-doc;
}
);
nixosConfigurations.testmachine = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./tests/disko-install/configuration.nix
./example/hybrid.nix
./module.nix
];
};
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.writeShellApplication {
name = "treefmt";
text = ''treefmt "$@"'';
runtimeInputs = [
pkgs.deadnix
pkgs.nixfmt
pkgs.shellcheck
pkgs.treefmt
];
}
);
devShells = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
packages = [
self.formatter.${system}
self.packages.${system}.default
];
};
});
};
}