Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Check Nix formatting
run: |
nix develop --command nixpkgs-fmt --check flake.nix
git ls-files '*.nix' | xargs nix develop --command nixfmt --check

- name: nix flake check
run: |
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Check external links in README
run: |
nix develop --command \
lychee README.md
check-external-links

- name: check image label
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Link checker cache
.lycheecache

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ data "aws_ami" "detsys_nixos" {
[private-flakes]: https://docs.determinate.systems/flakehub/private-flakes
[ssm]: https://aws.amazon.com/systems-manager
[sts]: https://docs.aws.amazon.com/STS/latest/APIReference/welcome.html
[terraform]: https://terraform.io
[terraform]: https://developer.hashicorp.com/terraform
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 100 additions & 50 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@
nixos-amis.url = "https://flakehub.com/f/NixOS/amis/0.1.*";
};

outputs = { self, ... }@inputs:
outputs =
{ self, ... }@inputs:
let
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
allSystems = linuxSystems ++ [ "x86_64-darwin" "aarch64-darwin" ];
linuxSystems = [
"x86_64-linux"
"aarch64-linux"
];
allSystems = linuxSystems ++ [
"x86_64-darwin"
"aarch64-darwin"
];

forSystems = systems: f: inputs.nixpkgs.lib.genAttrs systems (system: f {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
};
lib = inputs.nixpkgs.lib;
});
forSystems =
systems: f:
inputs.nixpkgs.lib.genAttrs systems (
system:
f {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
};
lib = inputs.nixpkgs.lib;
}
);

forLinuxSystems = forSystems linuxSystems;
forAllSystems = forSystems allSystems;
Expand All @@ -27,52 +39,90 @@
# Update this, and the changelog *and* usage examples in the README, for breaking changes to the AMIs
epoch = builtins.toString 1;

nixosConfigurations = forLinuxSystems ({ system, pkgs, lib, ... }: lib.nixosSystem {
inherit system;
modules = [
"${inputs.nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix"
inputs.determinate.nixosModules.default
({ config, ... }: {
nixosConfigurations = forLinuxSystems (
{
system,
pkgs,
lib,
...
}:
lib.nixosSystem {
inherit system;
modules = [
"${inputs.nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix"
inputs.determinate.nixosModules.default
(
{ config, ... }:
{

system.nixos.tags = lib.mkForce [ ];
environment.systemPackages = [
inputs.fh.packages.${system}.default
pkgs.git
];
system.nixos.tags = lib.mkForce [ ];
environment.systemPackages = [
inputs.fh.packages.${system}.default
pkgs.git
];

virtualisation.diskSize = lib.mkForce (4 * 1024);
virtualisation.diskSize = lib.mkForce (4 * 1024);

assertions =
[{
assertion = ((
builtins.match
"^[0-9][0-9]\.[0-9][0-9]\..*"
config.system.nixos.label
) != null);
message = "nixos image label is incorrect";
}];
})
];
});
assertions = [
{
assertion = ((builtins.match "^[0-9][0-9]\.[0-9][0-9]\..*" config.system.nixos.label) != null);
message = "nixos image label is incorrect";
}
];
}
)
];
}
);

diskImages = forLinuxSystems ({ system, ... }: {
aws = self.nixosConfigurations.${system}.config.system.build.amazonImage;
});
diskImages = forLinuxSystems (
{ system, ... }:
{
aws = self.nixosConfigurations.${system}.config.system.build.amazonImage;
}
);

devShells = forAllSystems ({ system, pkgs, lib, ... }: {
default = pkgs.mkShell {
packages = with pkgs; [
lychee
nixpkgs-fmt
] ++ lib.optionals (builtins.elem system linuxSystems) [
inputs.nixos-amis.packages.${system}.upload-ami
];
};
});
devShells = forAllSystems (
{
system,
pkgs,
lib,
...
}:
{
default = pkgs.mkShell {
packages =
with pkgs;
[
lychee
(writeShellApplication {
name = "check-external-links";
runtimeInputs = with pkgs; [ lychee ];
text = ''
lychee \
--cache \
--max-concurrency 2 \
--verbose \
README.me
'';
})
self.formatter.${system}
]
++ lib.optionals (builtins.elem system linuxSystems) [
inputs.nixos-amis.packages.${system}.upload-ami
];
};
}
);

formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style);

apps = forLinuxSystems ({ system, ... }: {
smoke-test = inputs.nixos-amis.apps.${system}.smoke-test;
});
apps = forLinuxSystems (
{ system, ... }:
{
smoke-test = inputs.nixos-amis.apps.${system}.smoke-test;
}
);

schemas = inputs.flake-schemas.schemas // {
diskImages = {
Expand Down
1 change: 1 addition & 0 deletions result
Loading