Skip to content

Commit 98a3561

Browse files
authored
Add flake schema for epoch (#137)
* Remove default flake schemas * Update Nix formatter * Import only the necessary schemas * Update flake-schemas input * Add formatter output * Fix eval check * Remove x86_64-darwin * Move lib out of iterator * Add epoch to description string
1 parent ba21d6f commit 98a3561

File tree

3 files changed

+114
-60
lines changed

3 files changed

+114
-60
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ jobs:
2323
with:
2424
fail-mode: false
2525

26-
- uses: DeterminateSystems/nix-installer-action@main
27-
with:
28-
determinate: true
26+
- uses: DeterminateSystems/determinate-nix-action@main
2927

3028
- uses: DeterminateSystems/flakehub-cache-action@main
3129

3230
- name: Check Nix formatting
3331
run: |
34-
nix develop --command nixpkgs-fmt --check flake.nix
32+
nix develop --command git ls-files -z '*.nix' | xargs -0 -r nix develop --command nixfmt --check
3533
3634
- name: nix flake check
3735
run: |

flake.lock

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

flake.nix

Lines changed: 107 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,30 @@
88
"github:DeterminateSystems/amis/grahamc/ignore-me-central-1";
99
};
1010

11-
outputs = { self, ... }@inputs:
11+
outputs =
12+
{ self, ... }@inputs:
1213
let
13-
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
14-
allSystems = linuxSystems ++ [ "x86_64-darwin" "aarch64-darwin" ];
14+
inherit (inputs.nixpkgs) lib;
1515

16-
forSystems = systems: f: inputs.nixpkgs.lib.genAttrs systems (system: f {
17-
inherit system;
18-
pkgs = import inputs.nixpkgs {
19-
inherit system;
20-
};
21-
lib = inputs.nixpkgs.lib;
22-
});
16+
linuxSystems = [
17+
"x86_64-linux"
18+
"aarch64-linux"
19+
];
20+
allSystems = linuxSystems ++ [
21+
"aarch64-darwin"
22+
];
23+
24+
forSystems =
25+
systems: f:
26+
lib.genAttrs systems (
27+
system:
28+
f {
29+
inherit system;
30+
pkgs = import inputs.nixpkgs {
31+
inherit system;
32+
};
33+
}
34+
);
2335

2436
forLinuxSystems = forSystems linuxSystems;
2537
forAllSystems = forSystems allSystems;
@@ -28,61 +40,105 @@
2840
# Update this, and the changelog *and* usage examples in the README, for breaking changes to the AMIs
2941
epoch = builtins.toString 1;
3042

31-
nixosConfigurations = forLinuxSystems ({ system, pkgs, lib, ... }: lib.nixosSystem {
32-
inherit system;
33-
modules = [
34-
"${inputs.nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix"
35-
inputs.determinate.nixosModules.default
36-
({ config, ... }: {
43+
nixosConfigurations = forLinuxSystems (
44+
{
45+
system,
46+
pkgs,
47+
...
48+
}:
49+
lib.nixosSystem {
50+
inherit system;
51+
modules = [
52+
"${inputs.nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix"
53+
inputs.determinate.nixosModules.default
54+
(
55+
{ config, ... }:
56+
{
3757

38-
system.nixos.tags = lib.mkForce [ ];
39-
environment.systemPackages = [
40-
inputs.fh.packages.${system}.default
41-
pkgs.git
42-
];
58+
system.nixos.tags = lib.mkForce [ ];
59+
environment.systemPackages = [
60+
inputs.fh.packages.${system}.default
61+
pkgs.git
62+
];
4363

44-
virtualisation.diskSize = lib.mkForce (4 * 1024);
64+
virtualisation.diskSize = lib.mkForce (4 * 1024);
4565

46-
assertions =
47-
[{
48-
assertion = ((
49-
builtins.match
50-
"^[0-9][0-9]\.[0-9][0-9]\..*"
51-
config.system.nixos.label
52-
) != null);
53-
message = "nixos image label is incorrect";
54-
}];
55-
})
56-
];
57-
});
66+
assertions = [
67+
{
68+
assertion = ((builtins.match "^[0-9][0-9]\.[0-9][0-9]\..*" config.system.nixos.label) != null);
69+
message = "nixos image label is incorrect";
70+
}
71+
];
72+
}
73+
)
74+
];
75+
}
76+
);
5877

59-
diskImages = forLinuxSystems ({ system, ... }: {
60-
aws = self.nixosConfigurations.${system}.config.system.build.amazonImage;
61-
});
78+
diskImages = forLinuxSystems (
79+
{ system, ... }:
80+
{
81+
aws = self.nixosConfigurations.${system}.config.system.build.amazonImage;
82+
}
83+
);
6284

63-
devShells = forAllSystems ({ system, pkgs, lib, ... }: {
64-
default = pkgs.mkShell {
65-
packages = with pkgs; [
66-
lychee
67-
nixpkgs-fmt
68-
] ++ lib.optionals (builtins.elem system linuxSystems) [
69-
inputs.nixos-amis.packages.${system}.upload-ami
70-
];
71-
};
72-
});
85+
devShells = forAllSystems (
86+
{
87+
system,
88+
pkgs,
89+
...
90+
}:
91+
{
92+
default = pkgs.mkShell {
93+
packages =
94+
with pkgs;
95+
[
96+
lychee
97+
self.formatter.${system}
98+
]
99+
++ lib.optionals (builtins.elem system linuxSystems) [
100+
inputs.nixos-amis.packages.${system}.upload-ami
101+
];
102+
};
103+
}
104+
);
105+
106+
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt);
73107

74-
apps = forLinuxSystems ({ system, ... }: {
75-
smoke-test = inputs.nixos-amis.apps.${system}.smoke-test;
76-
});
108+
apps = forLinuxSystems (
109+
{ system, ... }:
110+
{
111+
smoke-test = inputs.nixos-amis.apps.${system}.smoke-test;
112+
}
113+
);
77114

78-
schemas = inputs.flake-schemas.schemas // {
115+
schemas = {
116+
inherit (inputs.flake-schemas.schemas)
117+
apps
118+
devShells
119+
formatter
120+
nixosConfigurations
121+
schemas
122+
;
123+
}
124+
// {
79125
diskImages = {
80126
version = 1;
81127
doc = ''
82128
The `diskImages` flake output contains derivations that build disk images for various execution environments.
83129
'';
84130
inventory = inputs.flake-schemas.lib.derivationsInventory "Disk image" false;
85131
};
132+
133+
epoch = {
134+
version = 1;
135+
doc = "The `epoch` output provides a simple string value that's meant to be updated whenever there are breaking changes to the AMIs.";
136+
inventory = output: {
137+
what = "Determinate NixOS AMIs epoch ${output}";
138+
shortDescription = "A string representing the epoch value: ${output}";
139+
evalChecks.isString = builtins.isString output;
140+
};
141+
};
86142
};
87143
};
88144
}

0 commit comments

Comments
 (0)