nixos-config/flake.nix

192 lines
5.7 KiB
Nix

{
description = "System config";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
sops = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
ha-now-playing = {
url = "git+https://git.datarift.nl/erwin/ha-now-playing.git?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
inputs.naersk.follows = "naersk";
inputs.rust-overlay.follows = "rust-overlay";
};
pamedia = {
url = "git+https://git.datarift.nl/erwin/pamedia-rs.git?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
inputs.naersk.follows = "naersk";
};
sunshine = {
url = "git+ssh://git@git.datarift.nl/erwin/sunshine.git?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{ self
, nixos-hardware
, sops
, ha-now-playing
, pamedia
, ...
} @ inputs:
with inputs; let
machines = import ./machines inputs;
defSystem = system: baseConfig:
nixpkgs.lib.nixosSystem {
system = "${system}";
modules = [
{ _module.args.inputs = inputs; }
{ _module.args.self-overlay = self.overlays.default; }
({ ... }: {
imports =
builtins.attrValues self.nixosModules
++ [
{
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nixpkgs.overlays = [
self.overlays.default
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
] ++ nixpkgs.lib.optional (system == "aarch64-linux")
(final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
});
}
baseConfig
home-manager.nixosModules.home-manager
{ home-manager.useUserPackages = true; }
];
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
})
sops.nixosModules.sops
inputs.sunshine.nixosModules.sunshine
];
};
in
{
overlays.default = import ./overlays;
# overlay = final: prev: {
# unstable = import nixpkgs {
# system = "x86_64-linux";
# config.allowUnfree = true;
# };
# };
nixosModules = builtins.listToAttrs (map
(x: {
name = x;
value = import (./modules + "/${x}");
})
(builtins.attrNames (builtins.readDir ./modules)));
inherit machines;
nixosConfigurations = builtins.listToAttrs (map
(machine: {
name = machine;
value = (defSystem (machines.${machine}.system or "x86_64-linux") {
imports = [
machines.${machine}.config
];
});
})
(builtins.attrNames machines));
}
// (flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ])
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
];
config = {
allowUnsupportedSystem = true;
allowUnfree = true;
};
};
in
rec {
packages = flake-utils.lib.flattenTree {
rofi-wayland = pkgs.rofi-wayland;
nix-plugins = pkgs.nix-plugins;
backscrub = pkgs.backscrub;
bl3auto = pkgs.bl3auto;
};
apps = {
rofi-wayland = flake-utils.lib.mkApp { drv = packages.rofi-wayland; };
nix-plugins = flake-utils.lib.mkApp { drv = packages.nix-plugins; };
backscrub = flake-utils.lib.mkApp { drv = packages.backscrub; };
};
devShells.default = with pkgs;
mkShell {
nativeBuildInputs = [
pkgs.sops
ssh-to-pgp
ssh-to-age
age
nodejs-18_x
nodePackages.typescript-language-server
nodePackages.yaml-language-server
inputs.nixos-generators.packages.${system}.nixos-generators
statix
multimarkdown
pngcrush
];
};
formatter = pkgs.nixpkgs-fmt;
}
);
}