From 97fcd6a9e53736565ad4c38624e2c348fc125e80 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 20 Feb 2024 17:19:08 -0600 Subject: [PATCH] Tearin' it up --- flake.lock | 20 ++++++-- flake.nix | 87 ++++++++++++++++----------------- lib/colors.nix | 4 +- modules/nixos/common.nix | 101 ++++++++++++++++++++------------------- nixos/base.nix | 16 +++---- nixos/beefcake.nix | 4 +- nixos/default.nix | 2 +- nixos/foxtrot.nix | 1 + overlays/default.nix | 11 +---- 9 files changed, 123 insertions(+), 123 deletions(-) diff --git a/flake.lock b/flake.lock index f47431c..fd682dc 100644 --- a/flake.lock +++ b/flake.lock @@ -230,6 +230,22 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1708296515, + "narHash": "sha256-FyF489fYNAUy7b6dkYV6rGPyzp+4tThhr80KNAaF/yY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "api-lyte-dev": "api-lyte-dev", @@ -308,9 +324,7 @@ }, "ssbm": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs_3", "slippi-desktop": "slippi-desktop" }, "locked": { diff --git a/flake.nix b/flake.nix index 0c6d6e1..18fd874 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ home-manager.inputs.nixpkgs.follows = "nixpkgs"; helix.url = "github:helix-editor/helix/master"; - # I think if I force this to follow nixpkgs, I won't get caching benefits + # I think if I force this to follow nixpkgs, I won't get caching benefits? # helix.inputs.nixpkgs.follows = "nixpkgs"; disko.url = "github:nix-community/disko/master"; @@ -26,19 +26,40 @@ api-lyte-dev.inputs.nixpkgs.follows = "nixpkgs"; ssbm.url = "github:lytedev/ssbm-nix"; - # I think if I force this to follow nixpkgs, I won't get caching benefits - ssbm.inputs.nixpkgs.follows = "nixpkgs"; + # ssbm.inputs.nixpkgs.follows = "nixpkgs"; # TODO: doesn't (can't?) support the forge mod loader yet # nix-minecraft.url = "github:Infinidoge/nix-minecraft"; }; + nixConfig = { + extra-experimental-features = ["nix-command" "flakes"]; + + extra-substituters = [ + "https://cache.nixos.org/" + "https://helix.cachix.org" + # "https://ssbm-nix.cachix.org" + "https://nix-community.cachix.org" + "https://nix.h.lyte.dev" + ]; + + extra-trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" + # "ssbm-nix.cachix.org-1:YN104LKAWaKQIecOphkftXgXlYZVK/IRHM1UD7WAIew=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0=" + ]; + }; + outputs = { self, nixpkgs, home-manager, + sops-nix, + disko, ... - } @ inputs: let + }: let inherit (self) outputs; systems = [ @@ -50,7 +71,7 @@ forAllSystems = nixpkgs.lib.genAttrs systems; in { - colors = (import ./lib/colors.nix inputs).schemes.catppuccin-mocha-sapphire; + colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire; # colors = (import ./lib/colors.nix inputs).color-schemes.donokai; font = { @@ -67,7 +88,7 @@ formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); # Your custom packages and modifications, exported as overlays - overlays = import ./overlays {inherit inputs;}; + overlays = import ./overlays; # Reusable nixos modules you might want to export # These are usually stuff you would upstream into nixpkgs @@ -77,6 +98,16 @@ # These are usually stuff you would upstream into home-manager homeManagerModules = import ./modules/home-manager; + # TODO: nix-on-droid for phone terminal usage? + # TODO: nix-darwin for work? + # TODO: nixos ISO? + + # Disk partition schemes and functions + diskoConfigurations = import ./disko; + + # Flake templates for easily setting up Nix in a project using common patterns I like + templates = import ./templates/all.nix; + # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = builtins.mapAttrs (name: { @@ -86,11 +117,11 @@ }: nixpkgs.lib.nixosSystem { inherit system; - specialArgs = { - inherit inputs outputs system; - }; modules = [ + sops-nix.nixosModules.sops + disko.nixosModules.disko + home-manager.nixosModules.home-manager self.nixosModules.common ] ++ modules; @@ -105,10 +136,6 @@ in home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; - extraSpecialArgs = { - inherit inputs outputs system; - inherit (outputs) colors font; - }; modules = with outputs.homeManagerModules; [ common { @@ -124,10 +151,6 @@ in home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; - extraSpecialArgs = { - inherit inputs outputs system; - inherit (outputs) colors font; - }; modules = with outputs.homeManagerModules; [ common { @@ -139,35 +162,5 @@ ]; }; }; - - # Disk partition schemes and functions - diskoConfigurations = import ./disko; - - # Flake templates for easily setting up Nix in a project using common patterns I like - templates = import ./templates/all.nix; - - # TODO: nix-on-droid for phone terminal usage? - # TODO: nix-darwin for work? - # TODO: nixos ISO? - }; - - nixConfig = { - extra-experimental-features = ["nix-command" "flakes"]; - - extra-substituters = [ - "https://cache.nixos.org/" - "https://helix.cachix.org" - "https://ssbm-nix.cachix.org" - "https://nix-community.cachix.org" - "https://nix.h.lyte.dev" - ]; - - extra-trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" - "ssbm-nix.cachix.org-1:YN104LKAWaKQIecOphkftXgXlYZVK/IRHM1UD7WAIew=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0=" - ]; }; } diff --git a/lib/colors.nix b/lib/colors.nix index 2a3c1d4..6e61945 100644 --- a/lib/colors.nix +++ b/lib/colors.nix @@ -1,4 +1,4 @@ -{nixpkgs, ...}: { +{lib, ...}: { schemes = let mkColorScheme = scheme @ { scheme-name, @@ -51,7 +51,7 @@ // scheme; in { - withHashPrefix = nixpkgs.lib.mapAttrs (_: value: "#${value}") base; + withHashPrefix = lib.mapAttrs (_: value: "#${value}") base; } // base; in { diff --git a/modules/nixos/common.nix b/modules/nixos/common.nix index 77baa35..4f3feef 100644 --- a/modules/nixos/common.nix +++ b/modules/nixos/common.nix @@ -1,27 +1,18 @@ { config, - lib, - inputs, - outputs, pkgs, modulesPath, ... }: let - inherit (pkgs) system; + inherit (pkgs) system lib; in { networking.hostName = lib.mkDefault "nixoslyte"; - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - inputs.sops-nix.nixosModules.sops - inputs.disko.nixosModules.disko - inputs.home-manager.nixosModules.home-manager - ] - ++ (with outputs.nixosModules; [ - avahi - daniel - ]); + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ./avahi.nix + ./daniel.nix + ]; hardware.enableRedistributableFirmware = true; @@ -158,24 +149,24 @@ in { useXkbConfig = true; earlySetup = true; - colors = with outputs.colors; [ - bg - red - green - orange - blue - purple - yellow - fg3 - fgdim - red - green - orange - blue - purple - yellow - fg - ]; + # colors = with colors; [ + # bg + # red + # green + # orange + # blue + # purple + # yellow + # fg3 + # fgdim + # red + # green + # orange + # blue + # purple + # yellow + # fg + # ]; }; networking = { @@ -240,9 +231,9 @@ in { # You can add overlays here overlays = [ # Add overlays your own flake exports (from overlays and pkgs dir): - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.unstable-packages + # outputs.overlays.additions + # outputs.overlays.modifications + # outputs.overlays.unstable-packages # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default @@ -269,37 +260,51 @@ in { # This will add each flake input as a registry # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: {flake = value;}) inputs; + # registry = lib.mapAttrs (_: value: {flake = value;}) inputs; settings = { trusted-users = ["root" "daniel"]; + experimental-features = lib.mkDefault ["nix-command" "flakes"]; + substituters = [ "https://cache.nixos.org/" "https://helix.cachix.org" "https://nix-community.cachix.org" "https://nix.h.lyte.dev" ]; + trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0=" ]; - auto-optimise-store = true; + + # optimise.automatic = true; + # optimise.dates = ["03:45"]; + + # gc = { + # automatic = true; + # dates = "weekly"; + # options = "--delete-older-than 30d"; + # }; + + auto-optimise-store = false; }; - # registry = { - # self.flake = inputs.self; + registry = { + # lytedev_nix = inputs.self; + # self.lytedev_nix = inputs.self; - # nixpkgs = { - # from = { - # id = "nixpkgs"; - # type = "indirect"; - # }; - # flake = inputs.nixpkgs; - # }; - # }; + # nixpkgs = { + # from = { + # id = "nixpkgs"; + # type = "indirect"; + # }; + # flake = inputs.nixpkgs; + # }; + }; }; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; diff --git a/nixos/base.nix b/nixos/base.nix index 79fe271..9cb0fff 100644 --- a/nixos/base.nix +++ b/nixos/base.nix @@ -1,17 +1,13 @@ -{ - config, - outputs, - ... -}: { +{...}: { # a minimal, familiar setup that I can bootstrap atop - imports = with outputs.nixosModules; [ + imports = [ # may need to be tweaked based on the machine's paritioning scheme - outputs.diskoConfigurations.standard - desktop-usage - wifi + # outputs.diskoConfigurations.standard + # desktop-usage + # wifi ]; - networking.hostName = config.home-manager.users.daniel.home.username; + networking.hostName = "lytedev_nixos_base"; # TODO: may not work for non-UEFI? boot.loader.systemd-boot.enable = true; diff --git a/nixos/beefcake.nix b/nixos/beefcake.nix index 54b74fd..554a810 100644 --- a/nixos/beefcake.nix +++ b/nixos/beefcake.nix @@ -8,7 +8,7 @@ sudo nix run nixpkgs#ipmitool -- raw 0x30 0x30 0x01 0x00 sudo nix run nixpkgs#ipmitool -- raw 0x30 0x30 0x02 0xff 0x00 */ { - # inputs, + inputs, # outputs, # config, pkgs, @@ -22,7 +22,7 @@ in { ../modules/nixos/fonts.nix ] ++ [ - # inputs.api-lyte-dev.nixosModules.${system}.api-lyte-dev + inputs.api-lyte-dev.nixosModules.${system}.api-lyte-dev # inputs.nix-minecraft.nixosModules.minecraft-servers ]; diff --git a/nixos/default.nix b/nixos/default.nix index 66cd29c..8a41279 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -7,7 +7,7 @@ with builtins; (listToAttrs (map (name: { }) [ "base" "htpc" - "beefcake" + # "beefcake" "dragon" "foxtrot" "musicbox" diff --git a/nixos/foxtrot.nix b/nixos/foxtrot.nix index ca176db..6756bfb 100644 --- a/nixos/foxtrot.nix +++ b/nixos/foxtrot.nix @@ -32,6 +32,7 @@ in { discord slack godot_4 + fractal variety # wallpaper switcher that I use with GNOME radeontop sops diff --git a/overlays/default.nix b/overlays/default.nix index 85a4d03..a665118 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,4 @@ -{inputs, ...}: { +{ # This one brings our custom packages from the 'pkgs' directory additions = final: _prev: import ../pkgs {pkgs = final;}; @@ -7,13 +7,4 @@ # https://nixos.wiki/wiki/Overlays modifications = final: prev: { }; - - # When applied, the unstable nixpkgs set (declared in the flake inputs) will - # be accessible through 'pkgs.unstable' - unstable-packages = final: _prev: { - unstable = import inputs.nixpkgs { - system = final.system; - config.allowUnfree = true; - }; - }; }