Skip to content
Draft
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
2 changes: 1 addition & 1 deletion flake.lock

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

151 changes: 99 additions & 52 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@
nixpkgs.url = "https://flakehub.com/f/nixos/nixpkgs/0.1.*";
determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/*";
fh.url = "https://flakehub.com/f/DeterminateSystems/fh/0.1.*";
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.5";
nixos-amis.url = "https://flakehub.com/f/NixOS/amis/0.1.*";
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/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,61 +39,96 @@
# 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
nixpkgs-fmt
]
++ lib.optionals (builtins.elem system linuxSystems) [
inputs.nixos-amis.packages.${system}.upload-ami
];
};
}
);

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 // {
schemas = {
diskImages = {
version = 1;
doc = ''
The `diskImages` flake output contains derivations that build disk images for various execution environments.
'';
inventory = inputs.flake-schemas.lib.derivationsInventory "Disk image" false;
};

epoch = {
version = 1;
doc = "The `epoch` output provides a simple string value that's meant to be updated whenever there are breaking changes to the AMIs.";
inventory = output: {
what = "Epoch string";
shortDescription = "A string representing the epoch value: ${output}";
evalChecks.isString = e: builtins.isString e;
};
};
};
};
}
Loading