nixos-config/flake.nix

240 lines
6.7 KiB
Nix
Raw Normal View History

2021-10-05 23:45:02 +02:00
{
description = "System config";
inputs = {
2021-11-12 17:10:17 +01:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2021-10-05 23:45:02 +02:00
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-12 07:23:46 +01:00
flake-utils.url = "github:numtide/flake-utils";
2021-10-05 23:45:02 +02:00
2022-01-24 11:17:44 +01:00
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";
};
2021-11-26 22:21:16 +01:00
sops = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-02-09 08:13:16 +01:00
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
};
# nix-doom-emacs = {
# url = "github:nix-community/nix-doom-emacs";
# inputs.nixpkgs.follows = "nixpkgs";
# inputs.flake-utils.follows = "flake-utils";
# };
2022-02-09 08:13:16 +01:00
cq-flake = {
url = "github:marcus7070/cq-flake";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
2022-03-01 22:18:44 +01:00
alejandra = {
url = "github:kamadorueda/alejandra";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-21 19:07:12 +01:00
ha-now-playing = {
2022-02-22 20:10:35 +01:00
url = "git+ssh://git@git.datarift.nl/erwin/ha-now-playing.git?ref=main";
2021-11-21 19:07:12 +01:00
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
2022-01-24 11:17:44 +01:00
inputs.naersk.follows = "naersk";
inputs.rust-overlay.follows = "rust-overlay";
2021-11-21 19:07:12 +01:00
};
2021-10-05 23:45:02 +02:00
2021-11-21 19:07:12 +01:00
pamedia = {
2022-02-22 20:10:35 +01:00
url = "git+ssh://git@git.datarift.nl/erwin/pamedia-rs.git?ref=main";
2021-11-21 19:07:12 +01:00
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
2022-01-24 11:17:44 +01:00
inputs.naersk.follows = "naersk";
2021-11-21 19:07:12 +01:00
};
2021-11-12 07:23:46 +01:00
};
2021-10-05 23:45:02 +02:00
2022-03-01 22:19:03 +01:00
outputs = {
self,
sops,
ha-now-playing,
pamedia,
...
} @ inputs:
with inputs; let
2021-11-21 19:07:12 +01:00
defSystem = system: baseConfig:
2021-11-12 07:23:46 +01:00
nixpkgs.lib.nixosSystem {
2021-11-21 19:07:12 +01:00
system = "${system}";
2021-11-12 07:23:46 +01:00
modules = [
2022-03-01 22:19:03 +01:00
{_module.args.inputs = inputs;}
{_module.args.self-overlay = self.overlay;}
({...}: {
imports =
builtins.attrValues self.nixosModules
++ [
{
nix.nixPath = ["nixpkgs=${nixpkgs}"];
nixpkgs.overlays = [
self.overlay
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
];
}
baseConfig
home-manager.nixosModules.home-manager
{home-manager.useUserPackages = true;}
];
2022-01-24 11:17:44 +01:00
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
})
sops.nixosModules.sops
];
};
defContainer = system: baseConfig:
nixos-generators.nixosGenerate {
pkgs = nixpkgs.legacyPackages.${system};
format = "lxc";
modules = [
2022-03-01 22:19:03 +01:00
{_module.args.inputs = inputs;}
{_module.args.self-overlay = self.overlay;}
({...}: {
imports =
builtins.attrValues self.nixosModules
++ [
{
nix.nixPath = ["nixpkgs=${nixpkgs}"];
nixpkgs.overlays = [
self.overlay
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
];
}
baseConfig
home-manager.nixosModules.home-manager
{home-manager.useUserPackages = true;}
];
2021-11-12 07:23:46 +01:00
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
})
2021-11-26 22:21:16 +01:00
sops.nixosModules.sops
2021-11-12 07:23:46 +01:00
];
2021-10-05 23:45:02 +02:00
};
in
2022-03-01 22:19:03 +01:00
{
overlay = import ./overlays;
# overlay = final: prev: {
# unstable = import nixpkgs {
# system = "x86_64-linux";
# config.allowUnfree = true;
# };
# };
nixosModules = builtins.listToAttrs (map
2021-11-12 07:23:46 +01:00
(x: {
name = x;
value = import (./modules + "/${x}");
})
(builtins.attrNames (builtins.readDir ./modules)));
2021-10-05 23:45:02 +02:00
2022-03-01 22:19:03 +01:00
nixosConfigurations = {
vm1 = defSystem "x86_64-linux" {
imports = [
(import ./machines/vm1/configuration.nix {inherit self;})
];
};
vm2 = defSystem "x86_64-linux" {
imports = [
(import ./machines/vm2/configuration.nix {inherit self;})
];
};
2021-11-12 07:23:46 +01:00
2022-03-01 22:19:03 +01:00
loki = defSystem "x86_64-linux" {
imports = [
(import ./machines/loki/configuration.nix {inherit self;})
];
};
2022-03-01 22:19:03 +01:00
drone = defSystem "x86_64-linux" {
imports = [
(import ./machines/drone/configuration.nix {inherit self;})
];
};
2022-01-25 08:33:18 +01:00
2022-03-01 22:19:03 +01:00
proxy = defSystem "x86_64-linux" {
imports = [
(import ./machines/proxy/configuration.nix {inherit self;})
];
};
2022-01-25 08:33:18 +01:00
};
2022-01-24 11:17:44 +01:00
2022-03-01 22:19:03 +01:00
nixosContainers = {
drone = defContainer "x86_64-linux" {
imports = [
(import ./machines/drone/configuration.nix {inherit self;})
];
};
2022-01-25 08:33:18 +01:00
2022-03-01 22:19:03 +01:00
proxy = defContainer "x86_64-linux" {
imports = [
(import ./machines/proxy/configuration.nix {inherit self;})
];
};
2022-01-24 11:17:44 +01:00
};
2022-03-01 22:19:03 +01:00
}
// (flake-utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"])
(
system: let
2021-11-12 07:23:46 +01:00
pkgs = import nixpkgs {
inherit system;
2021-11-21 19:07:12 +01:00
overlays = [
self.overlay
2021-11-25 17:18:13 +01:00
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
2021-11-21 19:07:12 +01:00
];
2021-11-12 07:23:46 +01:00
config = {
allowUnsupportedSystem = true;
allowUnfree = true;
};
};
2022-03-01 22:19:03 +01:00
in rec {
2021-11-12 07:23:46 +01:00
packages = flake-utils.lib.flattenTree {
rofi-wayland = pkgs.rofi-wayland;
2021-11-25 17:18:13 +01:00
nix-plugins = pkgs.nix-plugins;
2021-12-06 09:58:39 +01:00
backscrub = pkgs.backscrub;
2021-11-12 07:23:46 +01:00
};
apps = {
2022-03-01 22:19:03 +01:00
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;};
2021-11-12 07:23:46 +01:00
};
2021-11-26 22:21:16 +01:00
2022-03-01 22:19:03 +01:00
devShell = with pkgs;
mkShell {
nativeBuildInputs = [sops ssh-to-pgp];
packages = [sops];
};
2021-11-12 07:23:46 +01:00
}
);
2021-10-05 23:45:02 +02:00
}