Squash of #136
https://github.com/numtide/system-manager/pull/136 Contents: @r-vdp Avoid rec ac4a95a @r-vdp Avoid re-importing nixpkgs multiple times 21bd839 @r-vdp Avoid building the application twice 8706306 @r-vdp Run clippy as part of the check phase ca50566 @r-vdp flake.lock: Update 1d968fb @r-vdp Adapt systemd module after merge of NixOS/nixpkgs#311394 270e3f0 @r-vdp Add nix-vm-test flake input 58dd3f9 @r-vdp Merge remote-tracking branch 'origin/main' into reduce_flake_deps a92a05f @r-vdp flake.lock: Update 9843716 Co-authored-by: r-vdp <ramses@well-founded.dev>
This commit is contained in:
parent
37d944cc5f
commit
c099b40594
6 changed files with 188 additions and 152 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -62,9 +62,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.91"
|
version = "1.0.90"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
|
checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
|
|
@ -274,9 +274,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.88"
|
version = "1.0.87"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
|
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
21
flake.lock
generated
21
flake.lock
generated
|
|
@ -1,5 +1,25 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"nix-vm-test": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729365388,
|
||||||
|
"narHash": "sha256-PRBcv8IWfXlw7DLuljqyPVAqtcj3/7RtmsKCou8dhAg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-vm-test",
|
||||||
|
"rev": "62092e89a2a69fa63fb4f560f48e2f874d3393bb",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-vm-test",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729256560,
|
"lastModified": 1729256560,
|
||||||
|
|
@ -18,6 +38,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"nix-vm-test": "nix-vm-test",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
39
flake.nix
39
flake.nix
|
|
@ -1,10 +1,17 @@
|
||||||
{
|
{
|
||||||
description = "Manage system config using nix on any distro";
|
description = "Manage system config using nix on any distro";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
nix-vm-test = {
|
||||||
|
url = "github:numtide/nix-vm-test";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs }:
|
inputs:
|
||||||
let
|
let
|
||||||
systems = [
|
systems = [
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
|
@ -12,22 +19,22 @@
|
||||||
];
|
];
|
||||||
eachSystem =
|
eachSystem =
|
||||||
f:
|
f:
|
||||||
nixpkgs.lib.genAttrs systems (
|
inputs.nixpkgs.lib.genAttrs systems (
|
||||||
system:
|
system:
|
||||||
f {
|
f {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
lib = import ./nix/lib.nix { inherit nixpkgs; };
|
lib = import ./nix/lib.nix { inherit (inputs) nixpkgs; };
|
||||||
|
|
||||||
packages = eachSystem (
|
packages = eachSystem (
|
||||||
{ pkgs, system }:
|
{ pkgs, system }:
|
||||||
import ./packages.nix { inherit pkgs; }
|
import ./packages.nix { inherit pkgs; }
|
||||||
// {
|
// {
|
||||||
default = self.packages.${system}.system-manager;
|
default = inputs.self.packages.${system}.system-manager;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -37,7 +44,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Only useful for quick tests
|
# Only useful for quick tests
|
||||||
systemConfigs.default = self.lib.makeSystemConfig {
|
systemConfigs.default = inputs.self.lib.makeSystemConfig {
|
||||||
modules = [ ./examples/example.nix ];
|
modules = [ ./examples/example.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,31 +58,23 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
checks = (
|
checks = (
|
||||||
nixpkgs.lib.recursiveUpdate
|
inputs.nixpkgs.lib.recursiveUpdate
|
||||||
(eachSystem (
|
(eachSystem (
|
||||||
{ system, ... }:
|
{ system, ... }:
|
||||||
{
|
{
|
||||||
system-manager = self.packages.${system}.system-manager;
|
system-manager = inputs.self.packages.${system}.system-manager;
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
x86_64-linux =
|
x86_64-linux =
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
nix-vm-test-src = builtins.fetchTarball {
|
|
||||||
url = "https://github.com/numtide/nix-vm-test/archive/7901cec00670681b3e405565cb7bffe6a9368240.tar.gz";
|
|
||||||
sha256 = "0m82a40r3j7qinp3y6mh36da89dkwvpalz6a4znx9rqp6kh3885x";
|
|
||||||
};
|
|
||||||
nix-vm-test = import "${nix-vm-test-src}/lib.nix" {
|
|
||||||
inherit nixpkgs;
|
|
||||||
inherit system;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
(import ./test/nix/modules {
|
(import ./test/nix/modules {
|
||||||
inherit system;
|
inherit system;
|
||||||
inherit (nixpkgs) lib;
|
inherit (inputs.nixpkgs) lib;
|
||||||
inherit nix-vm-test;
|
nix-vm-test = inputs.nix-vm-test.lib.${system};
|
||||||
system-manager = self;
|
system-manager = inputs.self;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
22
nix/lib.nix
22
nix/lib.nix
|
|
@ -3,7 +3,8 @@
|
||||||
lib ? import "${nixpkgs}/lib",
|
lib ? import "${nixpkgs}/lib",
|
||||||
nixos ? "${nixpkgs}/nixos",
|
nixos ? "${nixpkgs}/nixos",
|
||||||
}:
|
}:
|
||||||
rec {
|
let
|
||||||
|
self = {
|
||||||
# Function that can be used when defining inline modules to get better location
|
# Function that can be used when defining inline modules to get better location
|
||||||
# reporting in module-system errors.
|
# reporting in module-system errors.
|
||||||
# Usage example:
|
# Usage example:
|
||||||
|
|
@ -31,7 +32,7 @@ rec {
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
_file = "${printAttrPos (builtins.unsafeGetAttrPos "a" { a = null; })}: inline module";
|
_file = "${self.printAttrPos (builtins.unsafeGetAttrPos "a" { a = null; })}: inline module";
|
||||||
_module.args = {
|
_module.args = {
|
||||||
pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; };
|
pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; };
|
||||||
utils = import "${nixos}/lib/utils.nix" {
|
utils = import "${nixos}/lib/utils.nix" {
|
||||||
|
|
@ -39,8 +40,7 @@ rec {
|
||||||
};
|
};
|
||||||
# Pass the wrapped system-manager binary down
|
# Pass the wrapped system-manager binary down
|
||||||
# TODO: Use nixpkgs version by default.
|
# TODO: Use nixpkgs version by default.
|
||||||
inherit
|
inherit (import ../packages.nix { inherit pkgs; })
|
||||||
(import ../packages.nix { pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; }; })
|
|
||||||
system-manager
|
system-manager
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
@ -57,9 +57,7 @@ rec {
|
||||||
] ++ modules;
|
] ++ modules;
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
# Get the system as it was defined in the modules.
|
inherit (config.nixpkgs) pkgs;
|
||||||
system = config.nixpkgs.hostPlatform;
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
|
||||||
|
|
||||||
returnIfNoAssertions =
|
returnIfNoAssertions =
|
||||||
drv:
|
drv:
|
||||||
|
|
@ -124,20 +122,22 @@ rec {
|
||||||
|
|
||||||
activateProfileSnippet =
|
activateProfileSnippet =
|
||||||
{ node, profile }:
|
{ node, profile }:
|
||||||
mkTestPreamble {
|
self.mkTestPreamble {
|
||||||
inherit node profile;
|
inherit node profile;
|
||||||
action = "activate";
|
action = "activate";
|
||||||
};
|
};
|
||||||
deactivateProfileSnippet =
|
deactivateProfileSnippet =
|
||||||
{ node, profile }:
|
{ node, profile }:
|
||||||
mkTestPreamble {
|
self.mkTestPreamble {
|
||||||
inherit node profile;
|
inherit node profile;
|
||||||
action = "deactivate";
|
action = "deactivate";
|
||||||
};
|
};
|
||||||
prepopulateProfileSnippet =
|
prepopulateProfileSnippet =
|
||||||
{ node, profile }:
|
{ node, profile }:
|
||||||
mkTestPreamble {
|
self.mkTestPreamble {
|
||||||
inherit node profile;
|
inherit node profile;
|
||||||
action = "prepopulate";
|
action = "prepopulate";
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
in
|
||||||
|
self
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@
|
||||||
example = "x86_64-linux";
|
example = "x86_64-linux";
|
||||||
default = throw "the option nixpkgs.hostPlatform needs to be set.";
|
default = throw "the option nixpkgs.hostPlatform needs to be set.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pkgs = lib.mkOption {
|
||||||
|
type = lib.types.pkgs;
|
||||||
|
description = ''The pkgs module argument.'';
|
||||||
|
default = pkgs;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
assertions = lib.mkOption {
|
assertions = lib.mkOption {
|
||||||
|
|
|
||||||
11
packages.nix
11
packages.nix
|
|
@ -31,6 +31,7 @@ in
|
||||||
pkg-config,
|
pkg-config,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
nix,
|
nix,
|
||||||
|
clippy,
|
||||||
}:
|
}:
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
pname = "system-manager";
|
pname = "system-manager";
|
||||||
|
|
@ -42,7 +43,15 @@ in
|
||||||
pkg-config
|
pkg-config
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
checkType = "debug"; # might not be required?
|
|
||||||
|
nativeCheckInputs = [
|
||||||
|
clippy
|
||||||
|
];
|
||||||
|
|
||||||
|
preCheck = ''
|
||||||
|
${lib.getExe pkgs.cargo} clippy
|
||||||
|
'';
|
||||||
|
|
||||||
# TODO: Is prefixing nix here the correct approach?
|
# TODO: Is prefixing nix here the correct approach?
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
wrapProgram $out/bin/system-manager \
|
wrapProgram $out/bin/system-manager \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue