nixos-config/flake.nix

341 lines
8.5 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";
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
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";
flake-utils.follows = "flake-utils";
};
};
microvm = {
url = "github:astro/microvm.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
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";
flake-utils.follows = "flake-utils";
};
};
nil = {
url = "github:oxalica/nil";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
rust-overlay.follows = "rust-overlay";
};
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
eww = {
url = "github:elkowar/eww";
inputs = {
nixpkgs.follows = "nixpkgs";
rust-overlay.follows = "rust-overlay";
};
};
anyrun = {
url = "github:Kirottu/anyrun";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-ld-rs = {
url = "github:nix-community/nix-ld-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
attic = {
url = "github:zhaofengli/attic";
# inputs.nixpkgs.follows = "nixpkgs";
};
colmena = {
url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
atuin = {
url = "github:atuinsh/atuin";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
caddy-with-plugins = {
url = "github:eboskma/caddy-with-plugins";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
treefmt-nix.follows = "treefmt-nix";
};
};
ha-now-playing = {
url = "git+https://git.datarift.nl/erwin/ha-now-playing.git?ref=main";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
rust-overlay.follows = "rust-overlay";
pre-commit-hooks.follows = "pre-commit-hooks";
};
};
pamedia = {
url = "git+https://git.datarift.nl/erwin/pamedia-rs.git?ref=main";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
naersk.follows = "naersk";
};
};
git-fs-monitor = {
url = "git+https://git.datarift.nl/erwin/git-fs-monitor.git?ref=main";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
rust-overlay.follows = "rust-overlay";
pre-commit-hooks.follows = "pre-commit-hooks";
};
};
};
outputs =
{
self,
sops,
flake-parts,
...
}@inputs:
with inputs;
let
machines = import ./machines inputs;
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
];
imports = [
inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
flake = {
lib = import ./lib inputs;
overlays.default = import ./overlays;
nixosModules = builtins.listToAttrs (
map (x: {
name = x;
value = import (./modules + "/${x}");
}) (builtins.attrNames (builtins.readDir ./modules))
);
nixosConfigurations = builtins.listToAttrs (
map (machine: {
name = machine;
value = self.lib.defSystem (machines.${machine}.system or "x86_64-linux") {
imports = [ machines.${machine}.config ];
} (machines.${machine}.deploy or null);
}) (builtins.attrNames machines)
);
colmena =
{
meta = {
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
specialArgs = {
inherit nixpkgs;
};
};
}
// builtins.listToAttrs (
map (machine: {
name = machine;
value = {
deployment = {
targetHost = machines.${machine}.deploy.host;
targetUser = "root"; # machines.${machine}.deploy.sshUser;
# targetUser = machines.${machine}.deploy.sshUser;
tags = machines.${machine}.deploy.tags or [ ];
};
imports = self.lib.systemModules (machines.${machine}.system or "x86_64-linux"
) machines.${machine}.config;
};
}) (builtins.filter (machine: machines.${machine} ? deploy) (builtins.attrNames machines))
);
};
perSystem =
{
self',
inputs',
pkgs,
config,
...
}:
{
pre-commit = {
settings = {
hooks = {
nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
deadnix.enable = true;
black.enable = true;
shellcheck = {
enable = true;
types_or = [ "executable" ];
};
shfmt.enable = true;
};
};
};
treefmt = {
projectRootFile = "flake.lock";
programs = {
black.enable = true;
deadnix.enable = true;
nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
shellcheck.enable = true;
shfmt = {
enable = true;
indent_size = 0;
};
};
};
packages = {
git-repo-go = pkgs.callPackage ./pkgs/git-repo-go { };
gitu = pkgs.callPackage ./pkgs/gitu { };
headscale-ui = pkgs.callPackage ./pkgs/headscale-ui { };
incus-ui = pkgs.callPackage ./pkgs/incus-ui { };
openfga = pkgs.callPackage ./pkgs/openfga { };
zed = pkgs.callPackage ./pkgs/zed { };
};
apps = {
zed = {
type = "app";
program = "${self'.packages.zed}/bin/Zed";
};
};
devShells.default =
with pkgs;
mkShell {
name = "dotfiles";
packages = [
age
config.packages.git-repo-go
inputs'.colmena.packages.colmena
just
libxkbcommon
lswt
multimarkdown
nix-diff
nix-init
nix-output-monitor
nix-prefetch
nix-prefetch-docker
nix-prefetch-github
nix-prefetch-scripts
nix-tree
nix-top
nix-update
nixfmt-rfc-style
nodejs
nodePackages.typescript-language-server
nodePackages.yaml-language-server
nodePackages.vscode-css-languageserver-bin
nodePackages.prettier
openssl
pciutils
pkgs.sops
ssh-to-age
taplo
yj
inputs'.disko.packages.disko
];
shellHook = ''
${config.pre-commit.installationScript}
'';
};
devShells.install =
with pkgs;
mkShell {
name = "install";
packages = [ inputs'.disko.packages.disko ];
};
};
};
}