dotfiles

My PC Dotfiles & Website
commit 705d8a394a5892d052168c92693ac8a419cba0f4
parent 7fdb741778f3a1d850955eea246968addb67e999
Author: maydayv7 <maydayv7@gmail.com>
Date:   Thu, 25 Apr 2024 10:10:29 +0530

feat: Reimplement support for specifying Package Channel for configuration build

Diffstat:

MREADME.md | 1+
Mdevices/README.md | 4++++
Mdevices/vortex.nix | 1+
Mflake.lock | 61++++++++++++++++++++++++++++++++-----------------------------
Mflake.nix | 29+++++++++++++++--------------
Mmodules/configuration.nix | 39++++++++++++++++++++-------------------
Mmodules/gui/theme.nix | 2+-
Mpackages/README.md | 2+-
Mpackages/flake.nix | 111++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
9 files changed, 145 insertions(+), 105 deletions(-)

diff --git a/README.md b/README.md @@ -514,6 +514,7 @@ You can navigate to the `README`s present in the various directories to know mor - [Hyprspace](https://github.com/KZDKM/Hyprspace) - [Hyprexpo](https://github.com/hyprwm/hyprland-plugins/tree/main/hyprexpo) - Add `devcontainer` for Github Codespaces +- Reimplement support for specifying Package Channel for configuration build ### v17 diff --git a/devices/README.md b/devices/README.md @@ -15,3 +15,7 @@ These are the options that can be used in addition to the ones exposed by the [` - `format`: Generates Output for Specified Target Format (See [this](https://github.com/nix-community/nixos-generators#supported-formats) for the list of supported formats) - `user` or `users` (---> `config.user.settings`): Used to specify Device User/Multiple Users per Device - Ex. `users = [ { name "1"; } { name = "2"; } ]` - `update`: Enable Automatic System Upgrades - Ex. `weekly` +- `channel`: Specify which Package Channel the system is built from - Ex. `unstable` + +> [!WARNING] +> Specifying any other package channel apart from `stable` may be untested and cause breakage diff --git a/devices/vortex.nix b/devices/vortex.nix @@ -2,6 +2,7 @@ system = "x86_64-linux"; name = "vortex"; description = "PC - Dell Inspiron 15 5000"; + channel = "stable"; timezone = "Asia/Kolkata"; locale = "IN"; diff --git a/flake.lock b/flake.lock @@ -158,7 +158,7 @@ "utils" ], "nixpkgs": [ - "nixpkgs" + "stable" ], "pre-commit-hooks-nix": "pre-commit-hooks-nix", "rust-overlay": "rust-overlay" @@ -308,7 +308,7 @@ "formatter": { "inputs": { "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -328,7 +328,7 @@ "framework": { "inputs": { "nixpkgs-lib": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -385,7 +385,7 @@ "generators": { "inputs": { "nixlib": [ - "nixpkgs" + "stable" ], "nixpkgs": [ "unstable" @@ -445,7 +445,7 @@ "home-manager": { "inputs": { "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -672,7 +672,7 @@ "index": { "inputs": { "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -739,22 +739,6 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1712939125, - "narHash": "sha256-G3wznglfDwSYF8obg+zVqJqA/fPmJnzgaELq4kTCopI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ec877443d62ed5268c741656657d1319554a55f4", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "release-23.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { - "locked": { "lastModified": 1712791164, "narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=", "owner": "NixOS", @@ -803,7 +787,7 @@ "proprietary": { "inputs": { "nixpkgs": [ - "nixpkgs" + "stable" ], "utils": "utils" }, @@ -839,9 +823,12 @@ "hyprsplit": "hyprsplit", "impermanence": "impermanence", "index": "index", - "nixpkgs": "nixpkgs_3", + "nixpkgs": [ + "stable" + ], "proprietary": "proprietary", "sops": "sops", + "stable": "stable", "stylix": "stylix", "systems": "systems_2", "unstable": "unstable", @@ -883,7 +870,7 @@ "unstable" ], "nixpkgs-stable": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -900,6 +887,22 @@ "type": "github" } }, + "stable": { + "locked": { + "lastModified": 1712939125, + "narHash": "sha256-G3wznglfDwSYF8obg+zVqJqA/fPmJnzgaELq4kTCopI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ec877443d62ed5268c741656657d1319554a55f4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, "stylix": { "inputs": { "base16": "base16", @@ -916,7 +919,7 @@ "home-manager" ], "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -1027,7 +1030,7 @@ "utils" ], "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { @@ -1046,7 +1049,7 @@ }, "vsppuccin": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1713019360, @@ -1065,7 +1068,7 @@ "wfvm": { "inputs": { "nixpkgs": [ - "nixpkgs" + "stable" ] }, "locked": { diff --git a/flake.nix b/flake.nix @@ -38,7 +38,8 @@ inputs = { ## Package Repositories ## # NixOS Packages Repository - nixpkgs.url = "github:NixOS/nixpkgs?ref=release-23.11"; + nixpkgs.follows = "stable"; + stable.url = "github:NixOS/nixpkgs?ref=release-23.11"; # Unstable Packages Repository unstable.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; @@ -46,7 +47,7 @@ # Proprietary Software proprietary = { url = "github:maydayv7/proprietary"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "stable"; }; # Packaged Games @@ -66,7 +67,7 @@ # Flakes Framework framework = { url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; + inputs.nixpkgs-lib.follows = "stable"; }; # Flake Utility Functions @@ -81,14 +82,14 @@ # Syntax Formatter formatter = { url = "github:numtide/treefmt-nix"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "stable"; }; ## Feature Modules # User Home Manager home-manager = { url = "github:nix-community/home-manager?ref=release-23.11"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "stable"; }; # Hardware Support @@ -98,7 +99,7 @@ boot = { url = "github:nix-community/lanzaboote/v0.3.0"; inputs = { - nixpkgs.follows = "nixpkgs"; + nixpkgs.follows = "stable"; flake-parts.follows = "framework"; flake-utils.follows = "utils"; }; @@ -109,7 +110,7 @@ url = "github:Mic92/sops-nix"; inputs = { nixpkgs.follows = "unstable"; - nixpkgs-stable.follows = "nixpkgs"; + nixpkgs-stable.follows = "stable"; }; }; @@ -120,7 +121,7 @@ generators = { url = "github:nix-community/nixos-generators"; inputs = { - nixlib.follows = "nixpkgs"; + nixlib.follows = "stable"; nixpkgs.follows = "unstable"; }; }; @@ -128,14 +129,14 @@ # Nix Index Database index = { url = "github:Mic92/nix-index-database"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "stable"; }; # Base16 Theming stylix = { url = "github:danth/stylix?ref=release-23.11"; inputs = { - nixpkgs.follows = "nixpkgs"; + nixpkgs.follows = "stable"; home-manager.follows = "home-manager"; }; }; @@ -174,7 +175,7 @@ vscode = { url = "github:nix-community/nix-vscode-extensions"; inputs = { - nixpkgs.follows = "nixpkgs"; + nixpkgs.follows = "stable"; flake-utils.follows = "utils"; }; }; @@ -182,7 +183,7 @@ # Windows VM Creator wfvm = { url = "git+https://git.m-labs.hk/M-Labs/wfvm"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "stable"; }; # Windows Apps Wrapper @@ -194,7 +195,7 @@ ## Configuration ## outputs = {self, ...} @ inputs: let - inherit (inputs.nixpkgs) lib; + inherit (inputs.stable) lib; map = import ./lib/map.nix lib; in inputs.framework.lib.mkFlake {inherit inputs;} { @@ -213,7 +214,7 @@ lib.recursiveUpdate (map.modules ./lib (file: import file lib)) { nixpkgs = lib; - build.device = import ./modules/configuration.nix {inherit lib inputs;}; + build.device = import ./modules/configuration.nix inputs; }; ## Configuration Template ## diff --git a/modules/configuration.nix b/modules/configuration.nix @@ -1,21 +1,7 @@ -{ - lib, - inputs, -}: let +inputs: let inherit (inputs) self; util = self.lib; inherit (self) files; - inherit (lib) fileContents makeOverridable mkIf; - inherit - (builtins) - attrValues - getAttr - hashString - map - removeAttrs - replaceStrings - substring - ; in ## Configuration Build Function ## { @@ -23,6 +9,7 @@ in name ? "nixos", description ? "", format ? null, + channel ? "stable", imports ? [], timezone, locale, @@ -37,8 +24,22 @@ in user ? null, users ? null, }: let - # Default Package Channel - pkgs = self.legacyPackages."${system}"; + # Package Channel + pkgs = self.channels."${system}"."${channel}"; + + # Configuration Libraries + inherit (inputs."${channel}") lib; + inherit (lib) fileContents makeOverridable mkIf; + inherit + (builtins) + attrValues + getAttr + hashString + map + removeAttrs + replaceStrings + substring + ; # User Build Function user' = { @@ -73,7 +74,7 @@ in inherit system; specialArgs = { inherit util inputs files; - lib = with inputs; nixpkgs.lib // {inherit (home-manager.lib) hm;}; + lib = lib // {inherit (inputs.home-manager.lib) hm;}; }; modules = [ @@ -139,7 +140,7 @@ in else true; # Version - stateVersion = fileContents "${inputs.nixpkgs}/.version"; + stateVersion = fileContents "${inputs."${channel}"}/.version"; configurationRevision = if (self ? rev) then self.rev diff --git a/modules/gui/theme.nix b/modules/gui/theme.nix @@ -91,7 +91,7 @@ in { user.homeConfig.stylix.targets = { bat.enable = mkIf shell true; - btop.enable = mkIf shell true; + #btop.enable = mkIf shell true; #yazi.enable = mkIf shell true; #!# Wait for release firefox.enable = false; vscode.enable = mkIf (exists "vscode") false; diff --git a/packages/README.md b/packages/README.md @@ -15,4 +15,4 @@ Then Nix will fail the build with an `error` message and give the correct hash ### Patches -The default package channel can be patched by simply dropping a valid `.patch` file into the `patches` directory +The default package channel (`stable`) can be patched by simply dropping a valid `.patch` file into the `patches` directory diff --git a/packages/flake.nix b/packages/flake.nix @@ -1,4 +1,5 @@ { + lib, util, inputs, ... @@ -14,46 +15,24 @@ in { inputs', pkgs, ... - }: (let - # Repository Configuration - config = import ../modules/nix/config.nix; + }: + rec { + # Default Package Channel + _module.args.pkgs = legacyPackages; + legacyPackages = channels.stable; - # Package Calling Function - call = rec { - __functor = _: name: pkg name {}; - pkg = name: args: pkgs.callPackage name ({inherit lib util pkgs;} // args); - script = name: - pkg name { - inherit inputs; - inherit (inputs.self) files; - }; - }; - in rec { - # Default Package Channel - _module.args.pkgs = legacyPackages; - legacyPackages = with inputs; let - src = nixpkgs; - patches = map.patches ./patches; - pkgs' = import src {inherit system;}; - in - ( - if !(any isPath patches) - then import src - else - import (pkgs'.applyPatches { - inherit src patches; - name = "nixpkgs-patched-${src.shortRev}"; - }) - ) rec { - inherit system config; + # Package Channels + channels = with inputs; let + # Repository Configuration + config = import ../modules/nix/config.nix; + # Package Overrides overlays = (attrValues self.overlays or {}) ++ [ vsppuccin.overlays.default (_: _: { custom = self.packages."${system}"; - unstable = import unstable {inherit system config;}; code = vscode.extensions."${system}"; gaming = gaming.packages."${system}"; @@ -66,17 +45,67 @@ in { // hyprsplit.packages."${system}"; }) ]; + in { + stable = let + src = stable; + patches = map.patches ./patches; + pkgs' = import src {inherit system;}; + in + ( + if !(any isPath patches) + then import src + else + import (pkgs'.applyPatches { + inherit src patches; + name = "nixpkgs-patched-${src.shortRev}"; + }) + ) { + inherit system config; + overlays = overlays ++ [(_: _: {inherit (channels) unstable;})]; + }; + + unstable = import unstable { + inherit system config; + overlays = overlays ++ [(_: _: {inherit (channels) stable;})]; + }; + }; + } + // (let + # Package Calling Function + call = rec { + __functor = _: name: pkg name {}; + pkg = name: args: pkgs.callPackage name ({inherit lib util pkgs;} // args); + script = name: + pkg name { + inherit inputs; + inherit (inputs.self) files; + }; }; + in { + # Custom Packages + apps = + map.modules ../scripts (name: inputs.utils.lib.mkApp {drv = call.script name;}) + // {default = self'.apps.nixos;}; + packages = + map.modules ./. call + // map.modules ../scripts call.script + // inputs'.proprietary.packages; + }); - # Custom Packages - apps = - map.modules ../scripts (name: inputs.utils.lib.mkApp {drv = call.script name;}) - // {default = self'.apps.nixos;}; - packages = - map.modules ./. call - // map.modules ../scripts call.script - // inputs'.proprietary.packages; - }); + # Channel Module + imports = [ + (_: + with lib; + inputs.framework.lib.mkTransposedPerSystemModule { + name = "channels"; + option = mkOption { + type = with types; attrsOf (lazyAttrsOf raw); + default = {nixpkgs = import inputs.nixpkgs {};}; + description = "Set of Package Channels"; + }; + file = ./flake.nix; + }) + ]; # Package Overrides flake.overlays = map.modules ./overlays import;