Skip to content

Commit e1f45e5

Browse files
committed
working example with blueprint specific nixos module
1 parent 74be977 commit e1f45e5

File tree

6 files changed

+58
-59
lines changed

6 files changed

+58
-59
lines changed

flake.lock

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

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
systems.url = "github:nix-systems/default";
77

88
extra-container.url = "github:erikarvstedt/extra-container";
9-
# extra-container.inputs.nixpkgs.follows = "nixpkgs";
9+
extra-container.inputs.nixpkgs.follows = "nixpkgs";
1010
};
1111

1212
outputs =

lib/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ let
206206

207207
publisherArgs = {
208208
inherit flake inputs;
209+
210+
# TODO: this isn't there.
209211
inherit (flake) perSystem;
210212
};
211213

modules/nixos/unrepro.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# handled by injectPublisherArgs
2+
{
3+
flake,
4+
5+
# throws an error; there might be a bug with this
6+
# perSystem,
7+
...
8+
}:
9+
10+
# this is the module that in the real scenario lives outside of the `runTest` caller code
11+
{
12+
config,
13+
pkgs,
14+
lib,
15+
...
16+
}:
17+
18+
{
19+
imports = [ flake.inputs.extra-container.nixosModules.default ];
20+
config =
21+
22+
# (mysteriously) broken:
23+
# pkgs.lib.mkIf true {
24+
25+
# works:
26+
lib.mkIf true {
27+
environment.systemPackages = [
28+
# perSystem.self.packages.hello
29+
flake.packages.${pkgs.stdenv.system}.hello
30+
];
31+
};
32+
}

packages/default.nix

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,30 @@
1-
{ pkgs, flake, ... }:
1+
{
2+
pkgs,
3+
flake,
4+
system,
5+
...
6+
}:
27

3-
let
4-
lib = pkgs.lib;
5-
nixos = import (lib.path.append pkgs.path "nixos/lib") { inherit lib; };
6-
in
7-
nixos.runTest (
8-
/*
9-
TODO: what are these arguments? if i put pkgs in here i'm getting:
10-
11-
error: infinite recursion encountered
12-
at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/modules.nix:1016:24:
13-
1015| { _type = "override";
14-
1016| inherit priority content;
15-
| ^
16-
1017| };
17-
*/
18-
{ ... }:
8+
pkgs.testers.runNixOSTest (
9+
{ lib, ... }:
1910
{
2011
name = "nixos-test";
2112

22-
defaults._module.args = {
23-
inherit flake;
24-
};
25-
2613
nodes.machine =
27-
{ ... }:
14+
{ pkgs, ... }:
2815
{
29-
imports = [
30-
(
31-
# this is the module that in the real scenario lives outside of the `runTest` caller code
32-
{ config, pkgs, lib, flake, ... }:
33-
34-
{
35-
imports = [
36-
flake.inputs.extra-container.nixosModules.default
37-
];
38-
config =
39-
# mysteriously broken:
40-
# pkgs.lib.mkIf true { };
16+
imports = [ flake.nixosModules.unrepro ];
4117

42-
# works:
43-
lib.mkIf true { };
44-
}
45-
)
18+
environment.systemPackages = [
19+
(pkgs.writeShellScriptBin "hello2" ''
20+
exec ${lib.getExe flake.packages.${system}.hello}
21+
'')
4622
];
4723
};
4824

49-
testScript = _: '''';
50-
hostPkgs = pkgs;
25+
testScript = _: ''
26+
machine.succeed("hello")
27+
machine.succeed("hello2")
28+
'';
5129
}
5230
)

packages/hello.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ pkgs, ... }: pkgs.hello

0 commit comments

Comments
 (0)