learn-flakes-the-fun-way/flake.nix

53 lines
1.3 KiB
Nix

{
inputs.nixpkgs.url = "nixpkgs/nixos-24.05";
outputs = {
self,
nixpkgs,
...
}: let
systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"];
pkgsFor = func: (nixpkgs.lib.genAttrs systems (system: (func (import nixpkgs {inherit system;}))));
in {
packages = pkgsFor (pkgs: {
default = pkgs.callPackage ./what-is-my-ip.nix {};
container = pkgs.dockerTools.buildImage {
name = "what-is-my-ip-container";
config = {
Cmd = ["${self.outputs.packages.${pkgs.system}.default}/bin/what-is-my-ip"];
};
};
});
devShells = pkgsFor (pkgs: {
default = pkgs.mkShell {
packages = [self.outputs.packages.${pkgs.system}.default];
shellHook = ''
echo "Hello, Nix!"
'';
};
});
nixosConfigurations = let
system = "x86_64-linux";
in {
default = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{
users.users.alice = {
isNormalUser = true;
# enable sudo
extraGroups = ["wheel"];
packages = [
self.outputs.packages.${system}.default
];
initialPassword = "swordfish";
};
system.stateVersion = "24.05";
}
];
};
};
};
}