{ description = "Malte Tammena's system configuration"; inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; devshell.url = "github:numtide/devshell"; treefmt-nix.url = "github:numtide/treefmt-nix"; pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix"; nixpkgs.url = "nixpkgs/nixos-unstable"; nix.url = "github:NixOS/nix/2.19.2"; nixos-hardware.url = "github:NixOS/nixos-hardware"; custom-udev-rules.url = "github:MalteT/custom-udev-rules"; nix-colors.url = "github:Misterio77/nix-colors"; nixpkgs-wayland = { url = "github:nix-community/nixpkgs-wayland"; }; jovian-nixos = { url = "github:Jovian-Experiments/Jovian-NixOS"; inputs.nixpkgs.follows = "nixpkgs"; }; mensa = { url = "github:MalteT/mensa/main"; inputs.nixpkgs.follows = "nixpkgs"; }; sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; fend = { url = "github:MalteT/fend/flake"; inputs.nixpkgs.follows = "nixpkgs"; }; hydra = { url = "github:NixOS/hydra"; inputs.nix.follows = "nix"; }; hyprland = { url = "github:hyprwm/Hyprland"; inputs.nixpkgs.follows = "nixpkgs"; }; hyprland-contrib = { url = "github:hyprwm/contrib"; inputs.nixpkgs.follows = "nixpkgs"; }; qmk-udev-rules = { url = "github:qmk/qmk_firmware"; flake = false; }; }; nixConfig = { # Only usefull if you're part of my VPN extra-substituters = ["http://cache.home"]; }; outputs = inputs @ {flake-parts, ...}: let # Overlays useful to most of my systems overlaysSharedByAll = [ inputs.hyprland-contrib.overlays.default (_: super: { # Add my mensa tool inherit (inputs.mensa.packages.x86_64-linux) mensa; # TODO: Replace with upstream inherit (inputs.fend.packages.x86_64-linux) fend; hydra = inputs.hydra.packages.x86_64-linux.default; # TODO: Remove once hydra fixes these removed aliases inherit (super.perlPackages) buildPerlPackage; netcat-openbsd = super.libressl.nc; }) (import ./overlays/qmk-udev-rules.nix) ]; # Modules useful to most of my systems modulesSharedByAllSystems = [ inputs.sops-nix.nixosModules.sops inputs.self.nixosModules.nixUnstable inputs.home-manager.nixosModules.home-manager ./modules/base-system.nix ]; # The list of all hosts known to me listOfHosts = let hostDir = builtins.readDir ./hosts; in builtins.attrNames hostDir; in flake-parts.lib.mkFlake {inherit inputs;} { # Flake-parts modules to use imports = [ inputs.devshell.flakeModule inputs.treefmt-nix.flakeModule inputs.pre-commit-hooks-nix.flakeModule ]; # Available systems, only x86 for now systems = ["x86_64-linux"]; perSystem = { pkgs, self', config, ... }: { # Configure treefmt treefmt.projectRootFile = "flake.nix"; treefmt.programs = { alejandra.enable = true; shellcheck.enable = true; shfmt.enable = true; }; # Configure pre-commit checks pre-commit.settings.hooks.deadnix.enable = true; pre-commit.settings.hooks.treefmt.enable = true; pre-commit.settings.hooks.shellcheck.enable = true; pre-commit.settings.hooks.markdownlint.enable = true; # Load all packages from ./pkgs packages = let pkgFiles = builtins.attrNames (builtins.readDir ./pkgs); toPackage = file: { name = builtins.replaceStrings [".nix"] [""] file; value = pkgs.callPackage ./pkgs/${file} {inherit inputs;}; }; in builtins.listToAttrs (builtins.map toPackage pkgFiles); # Create a useable devshell for me devShells.default = pkgs.mkShell { name = "dev"; shellHook = '' ${config.pre-commit.installationScript} echo 1>&2 "Welcome to the development shell!" ''; packages = [ pkgs.nil pkgs.pre-commit pkgs.ssh-to-age self'.packages.rebuild self'.packages.personal-cache self'.packages.all-hosts self'.packages.option self'.packages.test-config ]; }; }; # Useful modules and all those from ./modules flake.nixosModules = { homeManagerConfig = _: { home-manager.verbose = true; home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = {inherit (inputs) nix-colors;}; }; nixUnstable = {pkgs, ...}: { nix.registry.nixpkgs.flake = inputs.nixpkgs; nix.package = pkgs.nixUnstable; nix.extraOptions = '' experimental-features = nix-command flakes ''; }; } // (let removeSuffix = builtins.replaceStrings [".nix"] [""]; moduleFiles = builtins.attrNames (builtins.readDir ./modules); listOfModules = builtins.map removeSuffix moduleFiles; toModule = name: { inherit name; value = builtins.readFile ./modules/${name}; }; in builtins.listToAttrs (builtins.map toModule listOfModules)); # All my system's configurations flake.nixosConfigurations = let genSystem = name: { inherit name; value = inputs.nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = {inherit inputs;}; modules = modulesSharedByAllSystems ++ [{nixpkgs.overlays = overlaysSharedByAll;} ./hosts/${name}/default.nix]; }; }; in builtins.listToAttrs (builtins.map genSystem listOfHosts); # Iso for USB flake.packages.x86_64-linux.iso = inputs.self.nixosConfigurations.radix-balthica.config.system.build.isoImage; # VM for testing flake.packages.x86_64-linux.vm = inputs.self.nixosConfigurations.radix-balthica.config.system.build.vm; # Copy most things to hydraJobs so hydra evaluates and builds them flake.hydraJobs = { inherit (inputs.self) packages devShells; nixosConfigurations.x86_64-linux = builtins.listToAttrs (builtins.map (name: { inherit name; value = inputs.self.nixosConfigurations.${name}.config.system.build.toplevel; }) listOfHosts); }; }; }