From 4a4bc737021044541ba487b6849638a5438b82ab Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Tue, 8 Nov 2022 16:12:00 -0300 Subject: [PATCH 1/9] remove multi-nixpkgs template I don't intend to maintain this template, right now. It'll still be available at a separate branch. This reverts commit 7bbdfe484c3cc96352fb141971d85ca379490a78. --- flake.nix | 6 -- multi-nixpkgs/flake.lock | 97 ------------------------------ multi-nixpkgs/flake.nix | 83 ------------------------- multi-nixpkgs/home-manager | 1 - multi-nixpkgs/modules | 1 - multi-nixpkgs/nixos | 1 - multi-nixpkgs/nixpkgs-config.nix | 1 - multi-nixpkgs/overlays/default.nix | 20 ------ multi-nixpkgs/pkgs | 1 - multi-nixpkgs/shell.nix | 1 - 10 files changed, 212 deletions(-) delete mode 100644 multi-nixpkgs/flake.lock delete mode 100644 multi-nixpkgs/flake.nix delete mode 120000 multi-nixpkgs/home-manager delete mode 120000 multi-nixpkgs/modules delete mode 120000 multi-nixpkgs/nixos delete mode 120000 multi-nixpkgs/nixpkgs-config.nix delete mode 100644 multi-nixpkgs/overlays/default.nix delete mode 120000 multi-nixpkgs/pkgs delete mode 120000 multi-nixpkgs/shell.nix diff --git a/flake.nix b/flake.nix index dda8d23..591094b 100644 --- a/flake.nix +++ b/flake.nix @@ -16,12 +16,6 @@ ''; path = ./standard; }; - multi-nixpkgs = { - description = '' - An example, based on the standard flake, on how to use two (or more) nixpkgs versions - ''; - path = ./multi-nixpkgs; - }; }; }; } diff --git a/multi-nixpkgs/flake.lock b/multi-nixpkgs/flake.lock deleted file mode 100644 index a197cb2..0000000 --- a/multi-nixpkgs/flake.lock +++ /dev/null @@ -1,97 +0,0 @@ -{ - "nodes": { - "hardware": { - "locked": { - "lastModified": 1667585378, - "narHash": "sha256-cvOwucrjBaAkaGk3FunG+MQiwiSBeIVTtO5n/YavpC0=", - "owner": "nixos", - "repo": "nixos-hardware", - "rev": "6b35a59c19ddbbeb229fcd1d3dcd422dcc0fa927", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixos-hardware", - "type": "github" - } - }, - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "utils": "utils" - }, - "locked": { - "lastModified": 1667574732, - "narHash": "sha256-73TVk3uSQOja6Q/5OuNcpcqwo6+SMzJPRtYAjU0rBx4=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "b764068a506c6f70dba998efa0e7fcb99cb4deb2", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1667482890, - "narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-master": { - "locked": { - "lastModified": 1667669848, - "narHash": "sha256-nD2dk2A+1zUlUT18ppDFVWwimi26+ultc2QRsulQwQ8=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "1f3ebb2bd1a353a42e8f833895c26d8415c7b791", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "hardware": "hardware", - "home-manager": "home-manager", - "nixpkgs": "nixpkgs", - "nixpkgs-master": "nixpkgs-master" - } - }, - "utils": { - "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/multi-nixpkgs/flake.nix b/multi-nixpkgs/flake.nix deleted file mode 100644 index 4c415f1..0000000 --- a/multi-nixpkgs/flake.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ - description = "Your new nix config"; - - inputs = { - # Nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nixpkgs-master.url = "github:nixos/nixpkgs/master"; - - # Home manager - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - - # TODO: Add any other flake you might need - hardware.url = "github:nixos/nixos-hardware"; - - # Shameless plug: looking for a way to nixify your themes and make - # everything match nicely? Try nix-colors! - # nix-colors.url = "github:misterio77/nix-colors"; - }; - - outputs = { nixpkgs, home-manager, ... }@inputs: - let - forAllSystems = nixpkgs.lib.genAttrs [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - in - rec { - # Your custom packages - # Acessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in - import ./pkgs { inherit pkgs; } - ); - # Devshell for bootstrapping - # Acessible through 'nix develop' or 'nix-shell' (legacy) - devShells = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in - import ./shell.nix { inherit pkgs; } - ); - - # Your custom packages and modifications, exported as overlays - overlays = import ./overlays { inherit inputs; }; - # Reusable nixos modules you might want to export - # These are usually stuff you would upstream into nixpkgs - nixosModules = import ./modules/nixos; - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager - homeManagerModules = import ./modules/home-manager; - - nixosConfigurations = { - # FIXME replace with your hostname - your-hostname = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; # Pass flake inputs to our config - modules = (builtins.attrValues nixosModules) ++ [ - # > Our main nixos configuration file < - ./nixos/configuration.nix - # Our common nixpkgs config (unfree, overlays, etc) - (import ./nixpkgs-config.nix { inherit overlays; }) - ]; - }; - }; - - homeConfigurations = { - # FIXME replace with your username@hostname - "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config - modules = (builtins.attrValues homeManagerModules) ++ [ - # > Our main home-manager configuration file < - ./home-manager/home.nix - # Our common nixpkgs config (unfree, overlays, etc) - (import ./nixpkgs-config.nix { inherit overlays; }) - ]; - }; - }; - }; -} diff --git a/multi-nixpkgs/home-manager b/multi-nixpkgs/home-manager deleted file mode 120000 index e047a58..0000000 --- a/multi-nixpkgs/home-manager +++ /dev/null @@ -1 +0,0 @@ -../standard/home-manager \ No newline at end of file diff --git a/multi-nixpkgs/modules b/multi-nixpkgs/modules deleted file mode 120000 index 3e9a3c5..0000000 --- a/multi-nixpkgs/modules +++ /dev/null @@ -1 +0,0 @@ -../standard/modules \ No newline at end of file diff --git a/multi-nixpkgs/nixos b/multi-nixpkgs/nixos deleted file mode 120000 index d159ef5..0000000 --- a/multi-nixpkgs/nixos +++ /dev/null @@ -1 +0,0 @@ -../standard/nixos \ No newline at end of file diff --git a/multi-nixpkgs/nixpkgs-config.nix b/multi-nixpkgs/nixpkgs-config.nix deleted file mode 120000 index 19056ba..0000000 --- a/multi-nixpkgs/nixpkgs-config.nix +++ /dev/null @@ -1 +0,0 @@ -../standard/nixpkgs-config.nix \ No newline at end of file diff --git a/multi-nixpkgs/overlays/default.nix b/multi-nixpkgs/overlays/default.nix deleted file mode 100644 index f520af5..0000000 --- a/multi-nixpkgs/overlays/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ inputs, ... }: -# This file defines overlays -{ - # Add bleeding edge packages under the 'master' namespace - master = final: _prev: { - master = inputs.nixpkgs-master.legacyPackages.${final.system}; - }; - - # This one brings our custom packages from the 'pkgs' directory - additions = final: _prev: import ../pkgs { pkgs = final; }; - - # This one contains whatever you want to overlay - # You can change versions, add patches, set compilation flags, anything really. - # https://nixos.wiki/wiki/Overlays - modifications = final: prev: { - # example = prev.example.overrideAttrs (oldAttrs: rec { - # ... - # }); - }; -} diff --git a/multi-nixpkgs/pkgs b/multi-nixpkgs/pkgs deleted file mode 120000 index 75370a4..0000000 --- a/multi-nixpkgs/pkgs +++ /dev/null @@ -1 +0,0 @@ -../standard/pkgs \ No newline at end of file diff --git a/multi-nixpkgs/shell.nix b/multi-nixpkgs/shell.nix deleted file mode 120000 index 123d7c8..0000000 --- a/multi-nixpkgs/shell.nix +++ /dev/null @@ -1 +0,0 @@ -../standard/shell.nix \ No newline at end of file From 7c8941a764da327ed8cb1653e4f56fb3983d0ef8 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Tue, 8 Nov 2022 17:59:31 -0300 Subject: [PATCH 2/9] reorganize modules and overlays This update makes using flake (self or external) modules and overlays more explicit, by setting nixpkgs options directly in the config, instead of the flake. To help import your own overlays and modules, the `outputs` attribute is now available on your configs. --- README.md | 19 ++------------- minimal/flake.lock | 24 +++++++++--------- minimal/home-manager/home.nix | 26 ++++++++++++++++++-- minimal/nixos/configuration.nix | 33 ++++++++++++++++++------- standard/flake.lock | 24 +++++++++--------- standard/flake.nix | 21 ++++++---------- standard/home-manager/home.nix | 37 +++++++++++++++++++++++++--- standard/nixos/configuration.nix | 42 ++++++++++++++++++++++++-------- standard/nixpkgs-config.nix | 10 -------- standard/nixpkgs.nix | 8 ++++++ standard/pkgs/default.nix | 7 +++--- standard/shell.nix | 24 ++++++------------ 12 files changed, 167 insertions(+), 108 deletions(-) delete mode 100644 standard/nixpkgs-config.nix create mode 100644 standard/nixpkgs.nix diff --git a/README.md b/README.md index 670462a..9c8537f 100644 --- a/README.md +++ b/README.md @@ -202,9 +202,9 @@ Found some outdated package on nixpkgs you need the latest version of? Perhaps you want to apply a patch to fix a behaviour you don't like? Nix makes it easy and manageble with overlays! -Use the `overlay/default.nix` file for this. +Use the `overlays/default.nix` file for this. -If you're creating patches, you can keep them on the `overlay` folder as well. +If you're creating patches, you can keep them on the `overlays` folder as well. See [the wiki article](https://nixos.wiki/wiki/Overlays) to see how it all works. @@ -228,21 +228,6 @@ Please [let me know](https://github.com/Misterio77/nix-starter-config/issues) any questions or issues you face with these templates, so I can add more info here! -## I'm trying to set nixpkgs.config options (e.g. allowUnfree), but they won't work! - -We instantiate nixpkgs and pass it to NixOS, to make the flake a bit simpler -and ensure both configs have the same nixpkgs instance, this has the drawback -of breaking nixpkgs configuration through in your NixOS config files. - -This is a design choice I made based on the `homeManagerConfiguration` -interface, that requires a `pkgs` instance anyway. If you prefer to set them -modularly, you'll have to remove the `pkgs` argument. If you use overlays, -you'll have to pass them into your configuration (through specialArgs) or set -`nixpkgs.overlays` right on the flake; in this case, you might prefer to use -[home-manager as a NixOS -module](https://nix-community.github.io/home-manager/index.html#sec-flakes-nixos-module) -and set `home-manager.useGlobalPkgs = true`. - ## Nix says my repo files don't exist, even though they do! Nix flakes only see files that git is currently tracked, so just `git add .` diff --git a/minimal/flake.lock b/minimal/flake.lock index 60d72e9..0fbb0a5 100644 --- a/minimal/flake.lock +++ b/minimal/flake.lock @@ -2,11 +2,11 @@ "nodes": { "hardware": { "locked": { - "lastModified": 1667585378, - "narHash": "sha256-cvOwucrjBaAkaGk3FunG+MQiwiSBeIVTtO5n/YavpC0=", + "lastModified": 1667768008, + "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "6b35a59c19ddbbeb229fcd1d3dcd422dcc0fa927", + "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1667574732, - "narHash": "sha256-73TVk3uSQOja6Q/5OuNcpcqwo6+SMzJPRtYAjU0rBx4=", + "lastModified": 1667898954, + "narHash": "sha256-VqHVeoxcOl9M6yQ+LV3yTWMb0h5Rl5yixn9PCY/MJJo=", "owner": "nix-community", "repo": "home-manager", - "rev": "b764068a506c6f70dba998efa0e7fcb99cb4deb2", + "rev": "d20e3d070c78271356a2d5d73c01f1de94586087", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667482890, - "narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=", + "lastModified": 1667811565, + "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8", + "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", "type": "github" }, "original": { @@ -61,11 +61,11 @@ }, "utils": { "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { diff --git a/minimal/home-manager/home.nix b/minimal/home-manager/home.nix index bafc020..58fc881 100644 --- a/minimal/home-manager/home.nix +++ b/minimal/home-manager/home.nix @@ -2,13 +2,35 @@ # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) { inputs, lib, config, pkgs, ... }: { + # You can import other home-manager modules here imports = [ - # If you want to use home-manager modules from other flakes (such as nix-colors), use something like: + # If you want to use home-manager modules from other flakes (such as nix-colors): # inputs.nix-colors.homeManagerModule - # Feel free to split up your configuration and import pieces of it here. + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix ]; + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + # TODO: Set your username home = { username = "your-username"; diff --git a/minimal/nixos/configuration.nix b/minimal/nixos/configuration.nix index 2997965..f4f824c 100644 --- a/minimal/nixos/configuration.nix +++ b/minimal/nixos/configuration.nix @@ -2,22 +2,39 @@ # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) { inputs, lib, config, pkgs, ... }: { - + # You can import other NixOS modules here imports = [ - # If you want to use modules from other flakes (such as nixos-hardware), use something like: + # If you want to use modules from other flakes (such as nixos-hardware): # inputs.hardware.nixosModules.common-cpu-amd # inputs.hardware.nixosModules.common-ssd - # It's strongly recommended you take a look at - # https://github.com/nixos/nixos-hardware - # and import modules relevant to your hardware. + # You can also split up your configuration and import pieces of it here: + # ./users.nix # Import your generated (nixos-generate-config) hardware configuration ./hardware-configuration.nix - - # You can also split up your configuration and import pieces of it here. ]; + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + nix = { # This will add each flake input as a registry # To make nix3 commands consistent with your flake @@ -26,9 +43,7 @@ # This will additionally add your inputs to the system's legacy channels # Making legacy nix commands consistent as well, awesome! nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - }; - nix = { settings = { # Enable flakes and new 'nix' command experimental-features = "nix-command flakes"; diff --git a/standard/flake.lock b/standard/flake.lock index 60d72e9..0fbb0a5 100644 --- a/standard/flake.lock +++ b/standard/flake.lock @@ -2,11 +2,11 @@ "nodes": { "hardware": { "locked": { - "lastModified": 1667585378, - "narHash": "sha256-cvOwucrjBaAkaGk3FunG+MQiwiSBeIVTtO5n/YavpC0=", + "lastModified": 1667768008, + "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "6b35a59c19ddbbeb229fcd1d3dcd422dcc0fa927", + "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1667574732, - "narHash": "sha256-73TVk3uSQOja6Q/5OuNcpcqwo6+SMzJPRtYAjU0rBx4=", + "lastModified": 1667898954, + "narHash": "sha256-VqHVeoxcOl9M6yQ+LV3yTWMb0h5Rl5yixn9PCY/MJJo=", "owner": "nix-community", "repo": "home-manager", - "rev": "b764068a506c6f70dba998efa0e7fcb99cb4deb2", + "rev": "d20e3d070c78271356a2d5d73c01f1de94586087", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667482890, - "narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=", + "lastModified": 1667811565, + "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8", + "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", "type": "github" }, "original": { @@ -61,11 +61,11 @@ }, "utils": { "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { diff --git a/standard/flake.nix b/standard/flake.nix index 97aead5..4cf1842 100644 --- a/standard/flake.nix +++ b/standard/flake.nix @@ -17,8 +17,9 @@ # nix-colors.url = "github:misterio77/nix-colors"; }; - outputs = { nixpkgs, home-manager, ... }@inputs: + outputs = { self, nixpkgs, home-manager, ... }@inputs: let + inherit (self) outputs; forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" "i686-linux" @@ -32,15 +33,13 @@ # Acessible through 'nix build', 'nix shell', etc packages = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; - in - import ./pkgs { inherit pkgs; } + in import ./pkgs { inherit pkgs; } ); # Devshell for bootstrapping # Acessible through 'nix develop' or 'nix-shell' (legacy) devShells = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; - in - import ./shell.nix { inherit pkgs; } + in import ./shell.nix { inherit pkgs; } ); # Your custom packages and modifications, exported as overlays @@ -55,12 +54,10 @@ nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; # Pass flake inputs to our config - modules = (builtins.attrValues nixosModules) ++ [ + specialArgs = { inherit inputs outputs; }; + modules = [ # > Our main nixos configuration file < ./nixos/configuration.nix - # Our common nixpkgs config (unfree, overlays, etc) - (import ./nixpkgs-config.nix { inherit overlays; }) ]; }; }; @@ -69,12 +66,10 @@ # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config - modules = (builtins.attrValues homeManagerModules) ++ [ + extraSpecialArgs = { inherit inputs outputs; }; + modules = [ # > Our main home-manager configuration file < ./home-manager/home.nix - # Our common nixpkgs config (unfree, overlays, etc) - (import ./nixpkgs-config.nix { inherit overlays; }) ]; }; }; diff --git a/standard/home-manager/home.nix b/standard/home-manager/home.nix index bafc020..02c1df1 100644 --- a/standard/home-manager/home.nix +++ b/standard/home-manager/home.nix @@ -1,14 +1,43 @@ # This is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) -{ inputs, lib, config, pkgs, ... }: { +{ inputs, outputs, lib, config, pkgs, ... }: { + # You can import other home-manager modules here imports = [ - # If you want to use home-manager modules from other flakes (such as nix-colors), use something like: - # inputs.nix-colors.homeManagerModule + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example - # Feel free to split up your configuration and import pieces of it here. + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix ]; + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays your own flake exports (from overlays dir): + # outputs.overlays.modifications + # outputs.overlays.additions + + # Or overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + # TODO: Set your username home = { username = "your-username"; diff --git a/standard/nixos/configuration.nix b/standard/nixos/configuration.nix index 27ec31f..7db9279 100644 --- a/standard/nixos/configuration.nix +++ b/standard/nixos/configuration.nix @@ -1,23 +1,47 @@ # This is your system's configuration file. # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) -{ inputs, lib, config, pkgs, ... }: { - +{ inputs, outputs, lib, config, pkgs, ... }: { + # You can import other NixOS modules here imports = [ - # If you want to use modules from other flakes (such as nixos-hardware), use something like: + # If you want to use modules your own flake exports (from modules/nixos): + # outputs.nixosModules.example + + # Or modules from other flakes (such as nixos-hardware): # inputs.hardware.nixosModules.common-cpu-amd # inputs.hardware.nixosModules.common-ssd - # It's strongly recommended you take a look at - # https://github.com/nixos/nixos-hardware - # and import modules relevant to your hardware. + # You can also split up your configuration and import pieces of it here: + # ./users.nix # Import your generated (nixos-generate-config) hardware configuration ./hardware-configuration.nix - - # You can also split up your configuration and import pieces of it here. ]; + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays your own flake exports (from overlays dir): + # outputs.overlays.modifications + # outputs.overlays.additions + + # Or overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + nix = { # This will add each flake input as a registry # To make nix3 commands consistent with your flake @@ -26,9 +50,7 @@ # This will additionally add your inputs to the system's legacy channels # Making legacy nix commands consistent as well, awesome! nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - }; - nix = { settings = { # Enable flakes and new 'nix' command experimental-features = "nix-command flakes"; diff --git a/standard/nixpkgs-config.nix b/standard/nixpkgs-config.nix deleted file mode 100644 index 84957b9..0000000 --- a/standard/nixpkgs-config.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ overlays, ... }: -{ - nixpkgs = { - config = { - allowUnfree = true; - }; - # Overlays is an attrset, convert to a list - overlays = builtins.attrValues overlays; - }; -} diff --git a/standard/nixpkgs.nix b/standard/nixpkgs.nix new file mode 100644 index 0000000..041de40 --- /dev/null +++ b/standard/nixpkgs.nix @@ -0,0 +1,8 @@ +# A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file +# This is useful to avoid using channels when using legacy nix commands +let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; +in +import (fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; + sha256 = lock.narHash; +}) diff --git a/standard/pkgs/default.nix b/standard/pkgs/default.nix index 55e428d..8c5e910 100644 --- a/standard/pkgs/default.nix +++ b/standard/pkgs/default.nix @@ -1,5 +1,6 @@ -# When you add custom packages, list them here -# These are similar to nixpkgs packages -{ pkgs }: { +# Custom packages, that can be defined similarly to ones from nixpkgs +# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' + +{ pkgs ? (import ../nixpkgs.nix) { } }: { # example = pkgs.callPackage ./example { }; } diff --git a/standard/shell.nix b/standard/shell.nix index 0ab6972..9525915 100644 --- a/standard/shell.nix +++ b/standard/shell.nix @@ -1,18 +1,10 @@ # Shell for bootstrapping flake-enabled nix and home-manager -{ pkgs ? let - # If pkgs is not defined, instantiate nixpkgs from locked commit - lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; - nixpkgs = fetchTarball { - url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; - sha256 = lock.narHash; - }; - system = builtins.currentSystem; - overlays = [ ]; # Explicit blank overlay to avoid interference - in - import nixpkgs { inherit system overlays; } -, ... -}: pkgs.mkShell { - # Enable experimental features without having to specify the argument - NIX_CONFIG = "experimental-features = nix-command flakes"; - nativeBuildInputs = with pkgs; [ nix home-manager git ]; +# You can enter it through 'nix develop' or (legacy) 'nix-shell' + +{ pkgs ? (import ./nixpkgs.nix) { } }: { + default = pkgs.mkShell { + # Enable experimental features without having to specify the argument + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = with pkgs; [ nix home-manager git ]; + }; } From 5f6910ff8ed104d18e9cf53f992d897a45c3730a Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Sun, 13 Nov 2022 16:59:09 -0300 Subject: [PATCH 3/9] minimal: remove leftover nixosSystem pkgs arg --- minimal/flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/minimal/flake.nix b/minimal/flake.nix index d1fb8f7..7d98891 100644 --- a/minimal/flake.nix +++ b/minimal/flake.nix @@ -21,7 +21,6 @@ nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { - pkgs = nixpkgs.legacyPackages.x86_64-linux; specialArgs = { inherit inputs; }; # Pass flake inputs to our config # > Our main nixos configuration file < modules = [ ./nixos/configuration.nix ]; @@ -31,7 +30,7 @@ homeConfigurations = { # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; + pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config # > Our main home-manager configuration file < modules = [ ./home-manager/home.nix ]; From cdf4442d1082b8b681fe4335fa9c6ce483e79126 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Sun, 13 Nov 2022 16:59:32 -0300 Subject: [PATCH 4/9] workaround for nix-community/home-manager#2942 --- minimal/home-manager/home.nix | 2 ++ standard/home-manager/home.nix | 2 ++ 2 files changed, 4 insertions(+) diff --git a/minimal/home-manager/home.nix b/minimal/home-manager/home.nix index 58fc881..a3645b4 100644 --- a/minimal/home-manager/home.nix +++ b/minimal/home-manager/home.nix @@ -28,6 +28,8 @@ config = { # Disable if you don't want unfree packages allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); }; }; diff --git a/standard/home-manager/home.nix b/standard/home-manager/home.nix index 02c1df1..6b2d124 100644 --- a/standard/home-manager/home.nix +++ b/standard/home-manager/home.nix @@ -35,6 +35,8 @@ config = { # Disable if you don't want unfree packages allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); }; }; From 80793d6a8df962aae8cdf44a35cb4c51d4d659a8 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Mon, 28 Nov 2022 08:58:25 -0300 Subject: [PATCH 5/9] add CC0 license --- LICENSE | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. From 5b6d9a064c179235b8cbf04c87300d15fee129f6 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Fri, 2 Dec 2022 15:19:40 -0300 Subject: [PATCH 6/9] update to nixos 22.11, add a couple comments --- minimal/flake.lock | 30 +++++++----------------------- minimal/flake.nix | 8 ++++++-- minimal/home-manager/home.nix | 2 +- minimal/nixos/configuration.nix | 4 ++-- standard/flake.lock | 30 +++++++----------------------- standard/flake.nix | 8 ++++++-- standard/home-manager/home.nix | 2 +- standard/nixos/configuration.nix | 4 ++-- 8 files changed, 32 insertions(+), 56 deletions(-) diff --git a/minimal/flake.lock b/minimal/flake.lock index 0fbb0a5..6b8c59c 100644 --- a/minimal/flake.lock +++ b/minimal/flake.lock @@ -1,20 +1,5 @@ { "nodes": { - "hardware": { - "locked": { - "lastModified": 1667768008, - "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", - "owner": "nixos", - "repo": "nixos-hardware", - "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixos-hardware", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -23,11 +8,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1667898954, - "narHash": "sha256-VqHVeoxcOl9M6yQ+LV3yTWMb0h5Rl5yixn9PCY/MJJo=", + "lastModified": 1669978198, + "narHash": "sha256-U8sZFwIIDFm9w/Kx58sYrIsWpuQUKmkcQmdBkuQ+gkE=", "owner": "nix-community", "repo": "home-manager", - "rev": "d20e3d070c78271356a2d5d73c01f1de94586087", + "rev": "71fa4cdf9cd89a3e0d452439b6a2f7f01d6292e9", "type": "github" }, "original": { @@ -38,23 +23,22 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667811565, - "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", + "lastModified": 1669834992, + "narHash": "sha256-YnhZGHgb4C3Q7DSGisO/stc50jFb9F/MzHeKS4giotg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", + "rev": "596a8e828c5dfa504f91918d0fa4152db3ab5502", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-22.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "hardware": "hardware", "home-manager": "home-manager", "nixpkgs": "nixpkgs" } diff --git a/minimal/flake.nix b/minimal/flake.nix index 7d98891..5a4d31e 100644 --- a/minimal/flake.nix +++ b/minimal/flake.nix @@ -3,14 +3,14 @@ inputs = { # Nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; # Home manager home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; # TODO: Add any other flake you might need - hardware.url = "github:nixos/nixos-hardware"; + # hardware.url = "github:nixos/nixos-hardware"; # Shameless plug: looking for a way to nixify your themes and make # everything match nicely? Try nix-colors! @@ -18,6 +18,8 @@ }; outputs = { nixpkgs, home-manager, ... }@inputs: { + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { @@ -27,6 +29,8 @@ }; }; + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { diff --git a/minimal/home-manager/home.nix b/minimal/home-manager/home.nix index a3645b4..ea28c5e 100644 --- a/minimal/home-manager/home.nix +++ b/minimal/home-manager/home.nix @@ -51,5 +51,5 @@ systemd.user.startServices = "sd-switch"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "22.05"; + home.stateVersion = "22.11"; } diff --git a/minimal/nixos/configuration.nix b/minimal/nixos/configuration.nix index f4f824c..bd8fd26 100644 --- a/minimal/nixos/configuration.nix +++ b/minimal/nixos/configuration.nix @@ -77,7 +77,7 @@ }; }; - # This sets up a SSH server. Very important if you're setting up a headless system. + # This setups a SSH server. Very important if you're setting up a headless system. # Feel free to remove if you don't need it. services.openssh = { enable = true; @@ -88,5 +88,5 @@ }; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "22.05"; + system.stateVersion = "22.11"; } diff --git a/standard/flake.lock b/standard/flake.lock index 0fbb0a5..6b8c59c 100644 --- a/standard/flake.lock +++ b/standard/flake.lock @@ -1,20 +1,5 @@ { "nodes": { - "hardware": { - "locked": { - "lastModified": 1667768008, - "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", - "owner": "nixos", - "repo": "nixos-hardware", - "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixos-hardware", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -23,11 +8,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1667898954, - "narHash": "sha256-VqHVeoxcOl9M6yQ+LV3yTWMb0h5Rl5yixn9PCY/MJJo=", + "lastModified": 1669978198, + "narHash": "sha256-U8sZFwIIDFm9w/Kx58sYrIsWpuQUKmkcQmdBkuQ+gkE=", "owner": "nix-community", "repo": "home-manager", - "rev": "d20e3d070c78271356a2d5d73c01f1de94586087", + "rev": "71fa4cdf9cd89a3e0d452439b6a2f7f01d6292e9", "type": "github" }, "original": { @@ -38,23 +23,22 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667811565, - "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", + "lastModified": 1669834992, + "narHash": "sha256-YnhZGHgb4C3Q7DSGisO/stc50jFb9F/MzHeKS4giotg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", + "rev": "596a8e828c5dfa504f91918d0fa4152db3ab5502", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-22.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "hardware": "hardware", "home-manager": "home-manager", "nixpkgs": "nixpkgs" } diff --git a/standard/flake.nix b/standard/flake.nix index 4cf1842..b19bf5f 100644 --- a/standard/flake.nix +++ b/standard/flake.nix @@ -3,14 +3,14 @@ inputs = { # Nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; # Home manager home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; # TODO: Add any other flake you might need - hardware.url = "github:nixos/nixos-hardware"; + # hardware.url = "github:nixos/nixos-hardware"; # Shameless plug: looking for a way to nixify your themes and make # everything match nicely? Try nix-colors! @@ -51,6 +51,8 @@ # These are usually stuff you would upstream into home-manager homeManagerModules = import ./modules/home-manager; + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { @@ -62,6 +64,8 @@ }; }; + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { diff --git a/standard/home-manager/home.nix b/standard/home-manager/home.nix index 6b2d124..dcce49e 100644 --- a/standard/home-manager/home.nix +++ b/standard/home-manager/home.nix @@ -58,5 +58,5 @@ systemd.user.startServices = "sd-switch"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "22.05"; + home.stateVersion = "22.11"; } diff --git a/standard/nixos/configuration.nix b/standard/nixos/configuration.nix index 7db9279..f73db0e 100644 --- a/standard/nixos/configuration.nix +++ b/standard/nixos/configuration.nix @@ -74,7 +74,7 @@ # TODO: You can set an initial password for your user. # If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. # Be sure to change it (using passwd) after rebooting! - # initialPassword = "correcthorsebatterystaple"; + initialPassword = "correcthorsebatterystaple"; isNormalUser = true; openssh.authorizedKeys.keys = [ # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect @@ -95,5 +95,5 @@ }; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "22.05"; + system.stateVersion = "22.11"; } From 8de736fe1aab6f67bcac323ff2203a34c5a27520 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Thu, 29 Dec 2022 19:38:17 -0300 Subject: [PATCH 7/9] add overlays and pkgs by default Related to https://github.com/Misterio77/nix-starter-configs/issues/16 --- standard/home-manager/home.nix | 8 ++++---- standard/nixos/configuration.nix | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/standard/home-manager/home.nix b/standard/home-manager/home.nix index dcce49e..9256458 100644 --- a/standard/home-manager/home.nix +++ b/standard/home-manager/home.nix @@ -17,11 +17,11 @@ nixpkgs = { # You can add overlays here overlays = [ - # If you want to use overlays your own flake exports (from overlays dir): - # outputs.overlays.modifications - # outputs.overlays.additions + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.modifications + outputs.overlays.additions - # Or overlays exported from other flakes: + # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default # Or define it inline, for example: diff --git a/standard/nixos/configuration.nix b/standard/nixos/configuration.nix index f73db0e..3745e4c 100644 --- a/standard/nixos/configuration.nix +++ b/standard/nixos/configuration.nix @@ -21,11 +21,11 @@ nixpkgs = { # You can add overlays here overlays = [ - # If you want to use overlays your own flake exports (from overlays dir): - # outputs.overlays.modifications - # outputs.overlays.additions + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.modifications + outputs.overlays.additions - # Or overlays exported from other flakes: + # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default # Or define it inline, for example: From 36bb43592a3cc13898a250b2c5ca5539825e0bdc Mon Sep 17 00:00:00 2001 From: Will Forman Date: Sun, 8 Jan 2023 18:12:46 +0000 Subject: [PATCH 8/9] Create new multi-nixpkgs dir from standard --- multi-nixpkgs/flake.lock | 64 ++++++++++++ multi-nixpkgs/flake.nix | 81 +++++++++++++++ multi-nixpkgs/home-manager/home.nix | 62 ++++++++++++ .../modules/home-manager/default.nix | 7 ++ multi-nixpkgs/modules/nixos/default.nix | 7 ++ multi-nixpkgs/nixos/configuration.nix | 99 +++++++++++++++++++ .../nixos/hardware-configuration.nix | 10 ++ multi-nixpkgs/nixpkgs.nix | 8 ++ multi-nixpkgs/overlays/default.nix | 14 +++ multi-nixpkgs/pkgs/default.nix | 6 ++ multi-nixpkgs/shell.nix | 10 ++ 11 files changed, 368 insertions(+) create mode 100644 multi-nixpkgs/flake.lock create mode 100644 multi-nixpkgs/flake.nix create mode 100644 multi-nixpkgs/home-manager/home.nix create mode 100644 multi-nixpkgs/modules/home-manager/default.nix create mode 100644 multi-nixpkgs/modules/nixos/default.nix create mode 100644 multi-nixpkgs/nixos/configuration.nix create mode 100644 multi-nixpkgs/nixos/hardware-configuration.nix create mode 100644 multi-nixpkgs/nixpkgs.nix create mode 100644 multi-nixpkgs/overlays/default.nix create mode 100644 multi-nixpkgs/pkgs/default.nix create mode 100644 multi-nixpkgs/shell.nix diff --git a/multi-nixpkgs/flake.lock b/multi-nixpkgs/flake.lock new file mode 100644 index 0000000..6b8c59c --- /dev/null +++ b/multi-nixpkgs/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1669978198, + "narHash": "sha256-U8sZFwIIDFm9w/Kx58sYrIsWpuQUKmkcQmdBkuQ+gkE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "71fa4cdf9cd89a3e0d452439b6a2f7f01d6292e9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1669834992, + "narHash": "sha256-YnhZGHgb4C3Q7DSGisO/stc50jFb9F/MzHeKS4giotg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "596a8e828c5dfa504f91918d0fa4152db3ab5502", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/multi-nixpkgs/flake.nix b/multi-nixpkgs/flake.nix new file mode 100644 index 0000000..b19bf5f --- /dev/null +++ b/multi-nixpkgs/flake.nix @@ -0,0 +1,81 @@ +{ + description = "Your new nix config"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; + + # Home manager + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # TODO: Add any other flake you might need + # hardware.url = "github:nixos/nixos-hardware"; + + # Shameless plug: looking for a way to nixify your themes and make + # everything match nicely? Try nix-colors! + # nix-colors.url = "github:misterio77/nix-colors"; + }; + + outputs = { self, nixpkgs, home-manager, ... }@inputs: + let + inherit (self) outputs; + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + in + rec { + # Your custom packages + # Acessible through 'nix build', 'nix shell', etc + packages = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in import ./pkgs { inherit pkgs; } + ); + # Devshell for bootstrapping + # Acessible through 'nix develop' or 'nix-shell' (legacy) + devShells = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in import ./shell.nix { inherit pkgs; } + ); + + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays; + # Reusable nixos modules you might want to export + # These are usually stuff you would upstream into nixpkgs + nixosModules = import ./modules/nixos; + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home-manager; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + # FIXME replace with your hostname + your-hostname = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main nixos configuration file < + ./nixos/configuration.nix + ]; + }; + }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + homeConfigurations = { + # FIXME replace with your username@hostname + "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance + extraSpecialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main home-manager configuration file < + ./home-manager/home.nix + ]; + }; + }; + }; +} diff --git a/multi-nixpkgs/home-manager/home.nix b/multi-nixpkgs/home-manager/home.nix new file mode 100644 index 0000000..9256458 --- /dev/null +++ b/multi-nixpkgs/home-manager/home.nix @@ -0,0 +1,62 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ inputs, outputs, lib, config, pkgs, ... }: { + # You can import other home-manager modules here + imports = [ + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example + + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix + ]; + + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.modifications + outputs.overlays.additions + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + # TODO: Set your username + home = { + username = "your-username"; + homeDirectory = "/home/your-username"; + }; + + # Add stuff for your user as you see fit: + # programs.neovim.enable = true; + # home.packages = with pkgs; [ steam ]; + + # Enable home-manager and git + programs.home-manager.enable = true; + programs.git.enable = true; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "22.11"; +} diff --git a/multi-nixpkgs/modules/home-manager/default.nix b/multi-nixpkgs/modules/home-manager/default.nix new file mode 100644 index 0000000..e41f7d9 --- /dev/null +++ b/multi-nixpkgs/modules/home-manager/default.nix @@ -0,0 +1,7 @@ +# Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. + +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/multi-nixpkgs/modules/nixos/default.nix b/multi-nixpkgs/modules/nixos/default.nix new file mode 100644 index 0000000..bec6184 --- /dev/null +++ b/multi-nixpkgs/modules/nixos/default.nix @@ -0,0 +1,7 @@ +# Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. + +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/multi-nixpkgs/nixos/configuration.nix b/multi-nixpkgs/nixos/configuration.nix new file mode 100644 index 0000000..3745e4c --- /dev/null +++ b/multi-nixpkgs/nixos/configuration.nix @@ -0,0 +1,99 @@ +# This is your system's configuration file. +# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) + +{ inputs, outputs, lib, config, pkgs, ... }: { + # You can import other NixOS modules here + imports = [ + # If you want to use modules your own flake exports (from modules/nixos): + # outputs.nixosModules.example + + # Or modules from other flakes (such as nixos-hardware): + # inputs.hardware.nixosModules.common-cpu-amd + # inputs.hardware.nixosModules.common-ssd + + # You can also split up your configuration and import pieces of it here: + # ./users.nix + + # Import your generated (nixos-generate-config) hardware configuration + ./hardware-configuration.nix + ]; + + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.modifications + outputs.overlays.additions + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + + nix = { + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + }; + }; + + # FIXME: Add the rest of your current configuration + + # TODO: Set your hostname + networking.hostName = "your-hostname"; + + # TODO: This is just an example, be sure to use whatever bootloader you prefer + boot.loader.systemd-boot.enable = true; + + # TODO: Configure your system-wide user settings (groups, etc), add more users as needed. + users.users = { + # FIXME: Replace with your username + your-username = { + # TODO: You can set an initial password for your user. + # If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. + # Be sure to change it (using passwd) after rebooting! + initialPassword = "correcthorsebatterystaple"; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect + ]; + # TODO: Be sure to add any other groups you need (such as networkmanager, audio, docker, etc) + extraGroups = [ "wheel" ]; + }; + }; + + # This setups a SSH server. Very important if you're setting up a headless system. + # Feel free to remove if you don't need it. + services.openssh = { + enable = true; + # Forbid root login through SSH. + permitRootLogin = "no"; + # Use keys only. Remove if you want to SSH using password (not recommended) + passwordAuthentication = false; + }; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "22.11"; +} diff --git a/multi-nixpkgs/nixos/hardware-configuration.nix b/multi-nixpkgs/nixos/hardware-configuration.nix new file mode 100644 index 0000000..dd00939 --- /dev/null +++ b/multi-nixpkgs/nixos/hardware-configuration.nix @@ -0,0 +1,10 @@ +# This is just an example, you should generate yours with nixos-generate-config and put it in here. +{ + fileSystems."/" = { + device = "/dev/sda1"; + fsType = "ext4"; + }; + + # Set your system kind (needed for flakes) + nixpkgs.hostPlatform = "x86_64-linux"; +} diff --git a/multi-nixpkgs/nixpkgs.nix b/multi-nixpkgs/nixpkgs.nix new file mode 100644 index 0000000..041de40 --- /dev/null +++ b/multi-nixpkgs/nixpkgs.nix @@ -0,0 +1,8 @@ +# A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file +# This is useful to avoid using channels when using legacy nix commands +let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; +in +import (fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; + sha256 = lock.narHash; +}) diff --git a/multi-nixpkgs/overlays/default.nix b/multi-nixpkgs/overlays/default.nix new file mode 100644 index 0000000..b2653c9 --- /dev/null +++ b/multi-nixpkgs/overlays/default.nix @@ -0,0 +1,14 @@ +# This file defines overlays +{ + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs { pkgs = final; }; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; +} diff --git a/multi-nixpkgs/pkgs/default.nix b/multi-nixpkgs/pkgs/default.nix new file mode 100644 index 0000000..8c5e910 --- /dev/null +++ b/multi-nixpkgs/pkgs/default.nix @@ -0,0 +1,6 @@ +# Custom packages, that can be defined similarly to ones from nixpkgs +# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' + +{ pkgs ? (import ../nixpkgs.nix) { } }: { + # example = pkgs.callPackage ./example { }; +} diff --git a/multi-nixpkgs/shell.nix b/multi-nixpkgs/shell.nix new file mode 100644 index 0000000..9525915 --- /dev/null +++ b/multi-nixpkgs/shell.nix @@ -0,0 +1,10 @@ +# Shell for bootstrapping flake-enabled nix and home-manager +# You can enter it through 'nix develop' or (legacy) 'nix-shell' + +{ pkgs ? (import ./nixpkgs.nix) { } }: { + default = pkgs.mkShell { + # Enable experimental features without having to specify the argument + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = with pkgs; [ nix home-manager git ]; + }; +} From 1318be736262057168d6ccd17ad870fdfe7d6654 Mon Sep 17 00:00:00 2001 From: Will Forman Date: Sun, 8 Jan 2023 18:20:22 +0000 Subject: [PATCH 9/9] Update multiple channel support --- README.md | 10 ++++++++++ multi-nixpkgs/flake.lock | 19 ++++++++++++++++++- multi-nixpkgs/flake.nix | 3 ++- multi-nixpkgs/home-manager/home.nix | 1 + multi-nixpkgs/nixos/configuration.nix | 1 + multi-nixpkgs/overlays/default.nix | 6 ++++++ 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c8537f..40c4a1a 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,16 @@ the latest and greatest nix3 flake-enabled command UX. # What next? +## Multiple nixpkgs channels + +`multi-nixpkgs` shows how to setup multiple nixpkgs channels. For example, using the stable channel you can add the unstable version of neovim like: + +``` +home.packages = with pkgs; [ + unstable.neovim +]; +``` + ## Adding more hosts or users You can organize them by hostname and username on `nixos` and `home-manager` diff --git a/multi-nixpkgs/flake.lock b/multi-nixpkgs/flake.lock index 6b8c59c..220e02c 100644 --- a/multi-nixpkgs/flake.lock +++ b/multi-nixpkgs/flake.lock @@ -37,10 +37,27 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1672953546, + "narHash": "sha256-oz757DnJ1ITvwyTovuwG3l9cX6j9j6/DH9eH+cXFJmc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a518c77148585023ff56022f09c4b2c418a51ef5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" } }, "utils": { diff --git a/multi-nixpkgs/flake.nix b/multi-nixpkgs/flake.nix index b19bf5f..a7d0764 100644 --- a/multi-nixpkgs/flake.nix +++ b/multi-nixpkgs/flake.nix @@ -4,6 +4,7 @@ inputs = { # Nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Home manager home-manager.url = "github:nix-community/home-manager"; @@ -43,7 +44,7 @@ ); # Your custom packages and modifications, exported as overlays - overlays = import ./overlays; + overlays = import ./overlays { inherit inputs; }; # Reusable nixos modules you might want to export # These are usually stuff you would upstream into nixpkgs nixosModules = import ./modules/nixos; diff --git a/multi-nixpkgs/home-manager/home.nix b/multi-nixpkgs/home-manager/home.nix index 9256458..53ba612 100644 --- a/multi-nixpkgs/home-manager/home.nix +++ b/multi-nixpkgs/home-manager/home.nix @@ -18,6 +18,7 @@ # You can add overlays here overlays = [ # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.unstable outputs.overlays.modifications outputs.overlays.additions diff --git a/multi-nixpkgs/nixos/configuration.nix b/multi-nixpkgs/nixos/configuration.nix index 3745e4c..98ea9fb 100644 --- a/multi-nixpkgs/nixos/configuration.nix +++ b/multi-nixpkgs/nixos/configuration.nix @@ -22,6 +22,7 @@ # You can add overlays here overlays = [ # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.unstable outputs.overlays.modifications outputs.overlays.additions diff --git a/multi-nixpkgs/overlays/default.nix b/multi-nixpkgs/overlays/default.nix index b2653c9..b068a55 100644 --- a/multi-nixpkgs/overlays/default.nix +++ b/multi-nixpkgs/overlays/default.nix @@ -1,5 +1,11 @@ +{ inputs, ... }: # This file defines overlays { + # Sets `unstable` under `pkgs` as the nixpkgs unstable channel + unstable = final: _prev: { + unstable = inputs.nixpkgs-unstable.legacyPackages.${final.system}; + }; + # This one brings our custom packages from the 'pkgs' directory additions = final: _prev: import ../pkgs { pkgs = final; };