nixos-config/flake.nix
Erwin Boskma d37889cdf9
Update flake.lock, add nixinate
• Updated input 'emacs-overlay':
    'github:nix-community/emacs-overlay/6b44cc8a441bed3796e6ddc984745fcdeaba8aa4' (2023-01-26)
  → 'github:nix-community/emacs-overlay/1e9e9e62a5a37c262b4f31ee8cc97d40894d1874' (2023-01-27)
• Updated input 'home-manager':
    'github:nix-community/home-manager/c59f0eac51da91c6989fd13a68e156f63c0e60b6' (2023-01-24)
  → 'github:nix-community/home-manager/bb4b25b302dbf0f527f190461b080b5262871756' (2023-01-26)
• Updated input 'hyprland':
    'github:Hyprwm/Hyprland/fc89e70a1fb74429ad0f772d399325f69e65b357' (2023-01-25)
  → 'github:Hyprwm/Hyprland/af37a3895f810ebe3cc58600b0d9b2fcf449b2d1' (2023-01-27)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/1b1f50645af2a70dc93eae18bfd88d330bfbcf7f' (2023-01-23)
  → 'github:nixos/nixpkgs/9b97ad7b4330aacda9b2343396eb3df8a853b4fc' (2023-01-25)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/7bdf85f6bbef581eb687838d19f2b35a4c9d77f0' (2023-01-24)
  → 'github:cachix/pre-commit-hooks.nix/8539119ba0b17b15e60de60da0348d8c73bbfdf2' (2023-01-26)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/480f9cc37db841d1fd3ac0b0c059d48e5eb6946c' (2023-01-26)
  → 'github:oxalica/rust-overlay/296dd673b46aaebe1c8355f1848ceb7c905dda35' (2023-01-27)
2023-01-27 20:44:05 +01:00

335 lines
9.9 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";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
nixinate = {
url = "github:MatthewCroughan/nixinate";
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";
};
microvm = {
url = "github:astro/microvm.nix";
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";
};
hyprland = {
url = "github:Hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs";
};
nil = {
url = "github:oxalica/nil";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
nomachine = {
url = "github:rytec-nl/nixpkgs/submit/add-nomachine-server";
};
ha-now-playing = {
url = "git+https://git.datarift.nl/erwin/ha-now-playing.git?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.naersk.follows = "naersk";
inputs.rust-overlay.follows = "rust-overlay";
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
};
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+https://git@git.datarift.nl/erwin/sunshine.git?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{ self
, sops
, ha-now-playing
, pamedia
, deploy-rs
, nixinate
, ...
} @ inputs:
with inputs; let
machines = import ./machines inputs;
defSystem = system: baseConfig: deployConfig:
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 =
let
nomachine-pkgs = import inputs.nomachine {
inherit system;
config.allowUnfree = true;
};
in
{
overlays = [
self.overlays.default
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
inputs.emacs-overlay.overlay
inputs.nil.overlays.default
(_final: _prev: {
nomachine = nomachine-pkgs.nomachine;
})
] ++ nixpkgs.lib.optional (system == "aarch64-linux")
(_final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
});
config.allowUnfree = 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
inputs.hyprland.nixosModules.default
] ++ (nixpkgs.lib.optional (deployConfig != null) { _module.args.nixinate = deployConfig; })
;
};
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)));
nixosConfigurations = builtins.listToAttrs (map
(machine: {
name = machine;
value = defSystem (machines.${machine}.system or "x86_64-linux")
{
imports = [
machines.${machine}.config
];
}
(machines.${machine}.deploy or null);
})
(builtins.attrNames machines));
apps = nixinate.nixinate.x86_64-linux self;
deploy.nodes = {
drone = {
hostname = "10.0.0.202";
profiles = {
system = {
sshUser = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.drone;
user = "root";
};
};
};
gitea = {
hostname = "10.0.0.201";
profiles = {
system = {
sshUser = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.gitea;
user = "root";
};
};
};
proxy = {
hostname = "10.0.0.251";
profiles = {
system = {
sshUser = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.proxy;
user = "root";
};
};
};
minio = {
hostname = "10.0.0.204";
profiles = {
system = {
sshUser = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.minio;
user = "root";
};
};
};
};
}
// (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;
};
};
# pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = flake-utils.lib.flattenTree {
rofi-wayland = pkgs.rofi-wayland;
nix-plugins = pkgs.nix-plugins;
backscrub = pkgs.backscrub;
bl3auto = pkgs.bl3auto;
commitgpt = pkgs.commitgpt;
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
deadnix.enable = true;
statix.enable = true;
black.enable = true;
shellcheck = {
enable = true;
types_or = [ "executable" ];
};
shfmt.enable = true;
};
};
}; # // deploy-rs.lib.${system}.deployChecks self.deploy;
devShells.default = with pkgs;
mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
name = "dotfiles";
nativeBuildInputs = [
pkgs.sops
ssh-to-age
age
nodejs-18_x
nodePackages.typescript-language-server
nodePackages.yaml-language-server
nodePackages.vscode-css-languageserver-bin
multimarkdown
nix-diff
nix-prefetch
nix-prefetch-scripts
nix-prefetch-github
nix-prefetch-docker
nixos-install-tools
deploy-rs.packages.${system}.deploy-rs
terraform
terraform-ls
disko.packages.${system}.disko
eww-wayland
];
};
devShells.install = with pkgs; mkShell {
name = "install";
nativeBuildInputs = [
disko.packages.${system}.disko
];
};
formatter = pkgs.nixpkgs-fmt;
}
);
}