{ description = "caedesyth system flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager.url = "github:nix-community/home-manager/release-24.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; # nixvim.url = "github:nix-community/nixvim"; # nixvim.inputs.nixpkgs.follows = "nixpkgs"; # nixvim.inputs.home-manager.follows = "home-manager"; nvf = { url = "github:notashelf/nvf"; inputs.nixpkgs.follows = "nixpkgs"; }; # Potentially, nvf asks you to include # obsidian-nvim.url = "github:epwalsh/obsidian.nvim"; stylix.url = "github:danth/stylix/release-24.11"; stylix.inputs.nixpkgs.follows = "nixpkgs"; stylix.inputs.home-manager.follows = "home-manager"; foundryvtt.url = "github:reckenrode/nix-foundryvtt"; foundryvtt.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, home-manager, stylix, nvf, ... } @ inputs: let inherit (self) outputs; system = "x86_64-linux"; rootPath = ./.; mkProfile = { hostname, username, isNixos, extraPkgs ? [], extraHomePkgs ? [], }: { inherit hostname username isNixos extraPkgs extraHomePkgs ; }; mkNixosConfiguration = profile: nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs profile rootPath ; }; modules = [ (./hosts + "/${profile.hostname}" + /configuration.nix) (./hosts + "/${profile.hostname}" + /hardware-configuration.nix) ./modules/nix stylix.nixosModules.stylix ./stylix ] ++ profile.extraPkgs; }; mkHomeConfiguration = profile: home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; extraSpecialArgs = { inherit inputs outputs profile rootPath ; unstablePkgs = inputs.nixpkgs-unstable.legacyPackages.${system}; }; modules = [ ./modules/home (./hosts + "/${profile.hostname}" + /home.nix) stylix.homeManagerModules.stylix nvf.homeManagerModules.default ./stylix ./stylix/home.nix ] ++ profile.extraHomePkgs; }; muko = mkProfile { hostname = "muko"; username = "muko"; isNixos = true; extraPkgs = [ ]; extraHomePkgs = []; }; typhon = mkProfile { hostname = "typhon"; username = "typhon"; isNixos = true; extraPkgs = [ inputs.foundryvtt.nixosModules.foundryvtt ]; extraHomePkgs = []; }; in { nixosConfigurations = { muko = mkNixosConfiguration muko; typhon = mkNixosConfiguration typhon; }; homeConfigurations = { muko = mkHomeConfiguration muko; typhon = mkHomeConfiguration typhon; }; formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; # Broken rn. We fixing it slowly packages.${system}.configurate = nixpkgs.legacyPackages.${system}.writeShellScriptBin "configurate" '' # If we error, crash out set -e set -o pipefail # To the configuration! pushd ${rootPath} nvim . # You need to edit the config dummy if git diff --quiet '*.nix'; then echo "Gotta change something!!" popd exit 0 fi # Clean it up nix fmt . &> /dev/null || (nix fmt .; echo "Formatting broke" && exit 1) # Show the clean stuff git diff -U0 "*.nix" echo "Rebuild time" sudo nixos-rebuild switch &> nixos-switch.log || (cat nixos-switch.log | grep --color error && exit 1) # Commit on success, with gen id as our commit message. No more lazygit :( current = $(nixos-rebuild list-generations | grep current) git commit -am "$current" popd # And a little friendly reminder. notify-send -e "Finished rebuilding NixOS!" --icon=software-update-available ''; }; }