nixfiles/flake.nix

110 lines
3.0 KiB
Nix
Raw Normal View History

2022-02-06 00:06:26 +00:00
{
description = "System configs";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
# Used by most systems
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
# For extra-stable systems
nixpkgs-stable.url = "nixpkgs/nixos-21.11";
# Stuff used by the flake for build / deployment
2022-02-06 00:06:26 +00:00
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs-unstable";
deploy-rs.url = "github:serokell/deploy-rs";
deploy-rs.inputs.nixpkgs.follows = "nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";
# Stuff used by systems
nix.url = "nix/latest-release";
#impermanence.url = "github:nix-community/impermanence";
impermanence.url = "github:devplayer0/impermanence/qemu-vm-dirs";
2022-02-06 00:06:26 +00:00
};
outputs =
inputs@{
self,
flake-utils,
nixpkgs-unstable, nixpkgs-stable,
...
}:
let
inherit (builtins) mapAttrs;
inherit (lib) genAttrs mapAttrs';
inherit (lib.flake) defaultSystems eachDefaultSystem;
2022-02-13 14:28:49 +00:00
inherit (lib.my) addPrefix mkApp mkShellApp;
2022-02-06 00:06:26 +00:00
extendLib = lib: lib.extend (final: prev: {
my = import ./util.nix { lib = final; };
flake = flake-utils.lib;
});
libOverlay = final: prev: { lib = extendLib prev.lib; };
pkgsFlakes = mapAttrs (_: pkgs: pkgs // { lib = extendLib pkgs.lib; }) {
unstable = nixpkgs-unstable;
stable = nixpkgs-stable;
};
lib = pkgsFlakes.unstable.lib;
2022-02-13 14:28:49 +00:00
pkgs' = mapAttrs
(_: path: lib.my.mkDefaultSystemsPkgs path {
overlays = [
libOverlay
inputs.agenix.overlay
inputs.deploy-rs.overlay
inputs.nix.overlay
];
})
pkgsFlakes;
2022-02-13 13:10:21 +00:00
in
2022-02-13 14:28:49 +00:00
# Platform independent stuff
2022-02-13 13:10:21 +00:00
{
2022-02-13 14:28:49 +00:00
lib = lib.my;
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
nixosModules = mapAttrs
(_: path:
let path' = ./. + "/modules/${path}"; in
{
_file = path';
imports = [ (import path') ];
})
{
common = "common.nix";
build = "build.nix";
dynamic-motd = "dynamic-motd.nix";
tmproot = "tmproot.nix";
firewall = "firewall.nix";
server = "server.nix";
};
2022-02-06 00:06:26 +00:00
nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; };
systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations;
2022-02-13 14:28:49 +00:00
vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations;
} //
(eachDefaultSystem (system:
let
pkgs = pkgs'.unstable.${system};
lib = pkgs.lib;
in
# Stuff for each platform
{
apps = {
fmt = mkShellApp pkgs "fmt" ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@" .'';
};
2022-02-06 00:06:26 +00:00
2022-02-13 14:28:49 +00:00
devShell = pkgs.mkShell {
packages = with pkgs; [
nix
agenix
deploy-rs.deploy-rs
nixpkgs-fmt
];
};
}));
2022-02-06 00:06:26 +00:00
}