nixos/flake.nix

73 lines
2.6 KiB
Nix
Raw Normal View History

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-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";
2022-10-25 19:56:22 +01:00
};
description = "Hillion Nix flake";
2023-06-05 22:35:44 +01:00
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-chia, agenix, home-manager, darwin, ... }@inputs: {
2023-01-11 20:34:07 +00:00
nixosConfigurations =
let
fqdns = builtins.attrNames (builtins.readDir ./hosts);
2023-03-17 21:35:13 +00:00
isNixos = fqdn: !builtins.pathExists ./hosts/${fqdn}/darwin;
2023-06-11 15:15:49 +01:00
getSystemOverlays = system: nixpkgsConfig: [
(final: prev: {
"storj" = final.callPackage ./pkgs/storj.nix { };
})
];
2023-01-11 20:34:07 +00:00
mkHost = fqdn:
2023-03-17 21:35:13 +00:00
let system = builtins.readFile ./hosts/${fqdn}/system;
in
2023-01-11 20:34:07 +00:00
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = inputs;
modules = [
./hosts/${fqdn}/default.nix
2023-04-07 21:37:23 +01:00
./modules/default.nix
2023-02-11 17:59:48 +00:00
agenix.nixosModules.default
2023-03-17 21:35:13 +00:00
home-manager.nixosModules.default
2023-06-11 15:15:49 +01:00
({ config, ... }: {
2023-06-11 19:08:23 +01:00
nix.registry.nixpkgs.flake = nixpkgs; # pin `nix shell` nixpkgs
2023-01-11 20:34:07 +00:00
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
2023-06-11 15:15:49 +01:00
nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config;
})
2023-01-11 20:34:07 +00:00
];
};
in
2023-03-17 21:35:13 +00:00
nixpkgs.lib.genAttrs (builtins.filter isNixos fqdns) mkHost;
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;
2022-12-28 13:59:16 +00:00
formatter."x86_64-linux" = nixpkgs.legacyPackages."x86_64-linux".nixpkgs-fmt;
formatter."aarch64-darwin" = nixpkgs.legacyPackages."aarch64-darwin".nixpkgs-fmt;
2022-10-25 19:56:22 +01:00
};
}