2022-10-25 19:56:22 +01:00
|
|
|
{
|
|
|
|
inputs = {
|
2023-07-08 15:50:31 +01:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
2022-12-04 15:01:05 +00:00
|
|
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
2023-06-10 09:32:27 +01:00
|
|
|
nixpkgs-chia.url = "github:lourkeur/nixpkgs?rev=e2b683787475d344892bddea9ab413dc611b894e";
|
2022-11-20 20:29:49 +00:00
|
|
|
|
2023-09-09 22:24:27 +01:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2023-03-17 21:35:13 +00:00
|
|
|
darwin.url = "github:lnl7/nix-darwin/master";
|
|
|
|
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-11-20 20:29:49 +00:00
|
|
|
agenix.url = "github:ryantm/agenix";
|
|
|
|
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
2023-01-11 20:22:35 +00:00
|
|
|
|
2023-07-08 15:50:31 +01:00
|
|
|
home-manager.url = "github:nix-community/home-manager/release-23.05";
|
2023-01-11 20:22:35 +00:00
|
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
2023-07-23 17:28:58 +01:00
|
|
|
|
|
|
|
impermanence.url = "github:nix-community/impermanence/master";
|
2022-10-25 19:56:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
description = "Hillion Nix flake";
|
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
outputs =
|
|
|
|
{ self, nixpkgs, nixpkgs-unstable, nixpkgs-chia, flake-utils, agenix, home-manager, impermanence, darwin, ... }@inputs:
|
|
|
|
let
|
|
|
|
fqdns = builtins.attrNames (builtins.readDir ./hosts);
|
|
|
|
isDarwin = host: builtins.pathExists ./hosts/${host}/darwin;
|
|
|
|
isNixos = fqdn: !isDarwin fqdn;
|
|
|
|
needsImage = fqdn: builtins.pathExists ./hosts/${fqdn}/image;
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
nixosConfigurations =
|
|
|
|
let
|
|
|
|
getSystemOverlays = system: nixpkgsConfig: [
|
|
|
|
(final: prev: {
|
|
|
|
"storj" = final.callPackage ./pkgs/storj.nix { };
|
|
|
|
})
|
|
|
|
];
|
|
|
|
mkHost = fqdn:
|
|
|
|
let system = builtins.readFile ./hosts/${fqdn}/system;
|
|
|
|
in
|
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
specialArgs = inputs;
|
|
|
|
modules = (if needsImage then [ ] else [ "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix" ]) ++ [
|
|
|
|
./hosts/${fqdn}/default.nix
|
|
|
|
./modules/default.nix
|
2023-07-23 17:28:58 +01:00
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
agenix.nixosModules.default
|
|
|
|
impermanence.nixosModules.impermanence
|
2023-07-23 17:28:58 +01:00
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
home-manager.nixosModules.default
|
|
|
|
{
|
|
|
|
home-manager.sharedModules = [
|
|
|
|
impermanence.nixosModules.home-manager.impermanence
|
|
|
|
];
|
|
|
|
}
|
2023-07-23 17:28:58 +01:00
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
({ config, ... }: {
|
|
|
|
nix.registry.nixpkgs.flake = nixpkgs; # pin `nix shell` nixpkgs
|
|
|
|
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
|
|
|
|
nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
nixpkgs.lib.genAttrs (builtins.filter isNixos fqdns) mkHost;
|
2023-03-17 21:35:13 +00:00
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
# images =
|
|
|
|
# let
|
|
|
|
# mkImage = fqdn: nixosConfigurations.${fqdn}.config.system.build.sdImage;
|
|
|
|
# in
|
|
|
|
# nixpkgs.lib.genAttrs (builtins.filter needsImage fqdns) mkImage;
|
|
|
|
|
|
|
|
images = {
|
|
|
|
"microserver" = nixosConfigurations."microserver.home.ts.hillion.co.uk".config.system.build.sdImage;
|
|
|
|
};
|
2022-12-28 13:59:16 +00:00
|
|
|
|
2023-09-08 20:51:42 +01:00
|
|
|
darwinConfigurations =
|
|
|
|
let
|
|
|
|
hosts = builtins.attrNames (builtins.readDir ./hosts);
|
|
|
|
isDarwin = host: builtins.pathExists ./hosts/${host}/darwin;
|
|
|
|
mkHost = host:
|
|
|
|
let system = builtins.readFile ./hosts/${host}/system;
|
|
|
|
in
|
|
|
|
darwin.lib.darwinSystem {
|
|
|
|
inherit system;
|
|
|
|
inherit inputs;
|
|
|
|
modules = [
|
|
|
|
./hosts/${host}/default.nix
|
|
|
|
agenix.darwinModules.default
|
|
|
|
home-manager.darwinModules.default
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
nixpkgs.lib.genAttrs (builtins.filter isDarwin hosts) mkHost;
|
|
|
|
} // flake-utils.lib.eachDefaultSystem (system: {
|
|
|
|
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
|
|
|
});
|
2022-10-25 19:56:22 +01:00
|
|
|
}
|