diff --git a/flake.nix b/flake.nix index 591094b..dda8d23 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,12 @@ ''; 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 new file mode 100644 index 0000000..a197cb2 --- /dev/null +++ b/multi-nixpkgs/flake.lock @@ -0,0 +1,97 @@ +{ + "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 new file mode 100644 index 0000000..4c415f1 --- /dev/null +++ b/multi-nixpkgs/flake.nix @@ -0,0 +1,83 @@ +{ + 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 new file mode 120000 index 0000000..e047a58 --- /dev/null +++ b/multi-nixpkgs/home-manager @@ -0,0 +1 @@ +../standard/home-manager \ No newline at end of file diff --git a/multi-nixpkgs/modules b/multi-nixpkgs/modules new file mode 120000 index 0000000..3e9a3c5 --- /dev/null +++ b/multi-nixpkgs/modules @@ -0,0 +1 @@ +../standard/modules \ No newline at end of file diff --git a/multi-nixpkgs/nixos b/multi-nixpkgs/nixos new file mode 120000 index 0000000..d159ef5 --- /dev/null +++ b/multi-nixpkgs/nixos @@ -0,0 +1 @@ +../standard/nixos \ No newline at end of file diff --git a/multi-nixpkgs/nixpkgs-config.nix b/multi-nixpkgs/nixpkgs-config.nix new file mode 120000 index 0000000..19056ba --- /dev/null +++ b/multi-nixpkgs/nixpkgs-config.nix @@ -0,0 +1 @@ +../standard/nixpkgs-config.nix \ No newline at end of file diff --git a/multi-nixpkgs/overlays/default.nix b/multi-nixpkgs/overlays/default.nix new file mode 100644 index 0000000..f520af5 --- /dev/null +++ b/multi-nixpkgs/overlays/default.nix @@ -0,0 +1,20 @@ +{ 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 new file mode 120000 index 0000000..75370a4 --- /dev/null +++ b/multi-nixpkgs/pkgs @@ -0,0 +1 @@ +../standard/pkgs \ No newline at end of file diff --git a/multi-nixpkgs/shell.nix b/multi-nixpkgs/shell.nix new file mode 120000 index 0000000..123d7c8 --- /dev/null +++ b/multi-nixpkgs/shell.nix @@ -0,0 +1 @@ +../standard/shell.nix \ No newline at end of file