How to install a specific version of a package from my configuration.nix

Hey guys, I appreciate the help and have tried all of the suggestions. Unfortunately nothing is working, and it’s really worrying that such a simple task is so complicated and error prone on nixos :confused:

The config:

      nixpkgs.config.packageOverrides = pkgs: {
        amuleDaemon =
          let
            pkgs-with-old-amule = import (builtins.fetchGit {
              name = "old-amule";
              url = "https://github.com/nixos/nixpkgs/";
              ref = "refs/heads/nixos-unstable";
              rev = "2c162d49cd5b979eb66ff1653aecaeaa01690fcc";
            }) {
              config = config.nixpkgs.config;
            };
          in
          pkgs-with-old-amule.amuleDaemon;
      };

Fails with:

error: attribute 'currentSystem' missing

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/pkgs/top-level/impure.nix:90:39:

           89|                 else (if args ? localSystem then {}
           90|                       else { system = builtins.currentSystem; }) // localSystem;
             |                                       ^
           91| })

The config:

      nixpkgs.config.packageOverrides = pkgs: {
        amuleDaemon = pkgs.amuleDaemon.overrideAttrs (oldAttrs: {
          src = pkgs.fetchFromGitHub {
            owner = "amule-project";
            repo = "amule";
            rev = "2.3.2";
            sha256 = "010wxm6g9f92x6fympj501zbnjka32rzbx0sk3a2y4zpih5d2nsn";
          };
        });
      };

Ignores the directive and tries to get the default amule 2.3.3 instead of 2.3.2 (which is even worse than erroring out because now you have silent failure):

error: Package ‘amule-2.3.3’ in /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/pkgs/tools/networking/p2p/amule/default.nix:55 is marked as broken, refusing to evaluate.

The config:

      nixpkgs.config.packageOverrides = pkgs: {
        amuleDaemon =
          let
            pkgs-with-old-amule = import (builtins.fetchGit {
              name = "old-amule";
              url = "https://github.com/nixos/nixpkgs/";
              ref = "refs/heads/nixos-unstable";
              rev = "2c162d49cd5b979eb66ff1653aecaeaa01690fcc";
            }) {
              config = config.nixpkgs.config;
              system = builtins.currentSystem; # Or you can set "x86_64" explicitly
              # Maybe this being a container is what makes `builtins.currentSystem` undefined?
            };
          in
          pkgs-with-old-amule.amuleDaemon;
      };

Fails with:

error: attribute 'currentSystem' missing

       at /nix/store/adppy720xyjlcbgmqzlbl2h75ypyb90a-source/container-mule.nix:40:24:

           39|               config = config.nixpkgs.config;
           40|               system = builtins.currentSystem; # Or you can set "x86_64" explicitly
             |                        ^
           41|               # Maybe this being a container is what makes `builtins.currentSystem` undefined?
(use '--show-trace' to show detailed location information)

Switching builtins.currentSystem to "x86_64":

      nixpkgs.config.packageOverrides = pkgs: {
        amuleDaemon =
          let
            pkgs-with-old-amule = import (builtins.fetchGit {
              name = "old-amule";
              url = "https://github.com/nixos/nixpkgs/";
              ref = "refs/heads/nixos-unstable";
              rev = "2c162d49cd5b979eb66ff1653aecaeaa01690fcc";
            }) {
              config = config.nixpkgs.config;
              system = "x86_64"; # Or you can set "x86_64" explicitly
              # Maybe this being a container is what makes `builtins.currentSystem` undefined?
            };
          in
          pkgs-with-old-amule.amuleDaemon;
      };

Fails with:

error: Target specification with 1 components is ambiguous
(use '--show-trace' to show detailed location information)

Adding --show-trace gives a 1400 line trace (cut short because of the 32000 character message limit):

[root@nas:/etc/nixos]# nixos-rebuild switch --show-trace --flake .
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: Target specification with 1 components is ambiguous

       … while evaluating the attribute '"1"'

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/parse.nix:370:5:

          369|   mkSkeletonFromList = l: {
          370|     "1" = if elemAt l 0 == "avr"
             |     ^
          371|       then { cpu = elemAt l 0; kernel = "none"; abi = "unknown"; }

       … while evaluating 'mkSkeletonFromList'

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/parse.nix:369:24:

          368|
          369|   mkSkeletonFromList = l: {
             |                        ^
          370|     "1" = if elemAt l 0 == "avr"

       … from call site

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/parse.nix:446:49:

          445|
          446|   mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
             |                                                 ^
          447|

       … while evaluating 'mkSystemFromString'

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/parse.nix:446:24:

          445|
          446|   mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
             |                        ^
          447|

       … from call site

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/default.nix:23:16:

           22|       # Prefer to parse `config` as it is strictly more informative.
           23|       parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);
             |                ^
           24|       # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.

       … while evaluating the attribute 'parsed.abi.assertions'

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/systems/default.nix:23:7:

           22|       # Prefer to parse `config` as it is strictly more informative.
           23|       parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);
             |       ^
           24|       # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.

       … while evaluating 'foldl''

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/lists.nix:82:16:

           81|     let
           82|       foldl' = n:
             |                ^
           83|         if n == -1

       … from call site

       at /nix/store/176g3d0sly5d602qf8wcljc15584zngz-old-amule/lib/lists.nix:86:8:

           85|         else op (foldl' (n - 1)) (elemAt list n);
           86|     in foldl' (length list - 1);
             |        ^
           87|

SNIP

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/attrsets.nix:301:19:

          300|           g =
          301|             name: value:
             |                   ^
          302|             if isAttrs value && cond value

       … from call site

       … while evaluating 'escapeShellArg'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/strings.nix:318:20:

          317|   */
          318|   escapeShellArg = arg: "'${replaceStrings ["'"] ["'\\''"] (toString arg)}'";
             |                    ^
          319|

       … from call site

       … while evaluating 'concatMapStringsSep'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/strings.nix:110:5:

          109|     # List of input strings
          110|     list: concatStringsSep sep (map f list);
             |     ^
          111|

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/etc/etc.nix:54:43:

           53|     mkdir -p "$out/etc"
           54|     ${concatMapStringsSep "\n" (etcEntry: escapeShellArgs [
             |                                           ^
           55|       "makeEtcEntry"

       … while evaluating anonymous lambda

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/etc/etc.nix:54:33:

           53|     mkdir -p "$out/etc"
           54|     ${concatMapStringsSep "\n" (etcEntry: escapeShellArgs [
             |                                 ^
           55|       "makeEtcEntry"

       … from call site

       … while evaluating 'concatMapStringsSep'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/strings.nix:110:5:

          109|     # List of input strings
          110|     list: concatStringsSep sep (map f list);
             |     ^
          111|

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/etc/etc.nix:54:7:

           53|     mkdir -p "$out/etc"
           54|     ${concatMapStringsSep "\n" (etcEntry: escapeShellArgs [
             |       ^
           55|       "makeEtcEntry"

       … while evaluating the attribute 'buildCommand' of the derivation 'etc'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

       … while evaluating the attribute 'value'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:452:44:

          451|       defnsByName' = byName "config" (module: value:
          452|           [{ inherit (module) file; inherit value; }]
             |                                            ^
          453|         ) configs;

       … while evaluating 'dischargeProperties'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:669:25:

          668|   */
          669|   dischargeProperties = def:
             |                         ^
          670|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:598:137:

          597|         defs' = concatMap (m:
          598|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          599|         ) defs;

       … while evaluating definitions from `/nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/etc/etc.nix':

       … while evaluating anonymous lambda

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:597:28:

          596|         # Process mkMerge and mkIf properties.
          597|         defs' = concatMap (m:
             |                            ^
          598|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:597:17:

          596|         # Process mkMerge and mkIf properties.
          597|         defs' = concatMap (m:
             |                 ^
          598|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:710:7:

          709|     in {
          710|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          711|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:611:9:

          610|       in {
          611|         values = defs''';
             |         ^
          612|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:617:5:

          616|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          617|     mergedValue =
             |     ^
          618|       if isDefined then

       … while evaluating the option `system.activationScripts.etc.text':

       … while evaluating the attribute 'value'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:585:9:

          584|     in warnDeprecation opt //
          585|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          586|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/modules.nix:171:72:

          170|           # For definitions that have an associated option
          171|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          172|

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/attrsets.nix:304:20:

          303|               then recurse (path ++ [name]) value
          304|               else f (path ++ [name]) value;
             |                    ^
          305|         in mapAttrs g set;

       … while evaluating 'g'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/attrsets.nix:301:19:

          300|           g =
          301|             name: value:
             |                   ^
          302|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'text'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/activation/activation-script.nix:9:5:

            8|   addAttributeName = mapAttrs (a: v: v // {
            9|     text = ''
             |     ^
           10|       #### Activation script snippet ${a}:

       … while evaluating 'id'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/trivial.nix:14:5:

           13|     # The value to return
           14|     x: x;
             |     ^
           15|

       … from call site

       … while evaluating 'textClosureMap'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/lib/strings-with-deps.nix:75:35:

           74|
           75|   textClosureMap = f: predefined: names:
             |                                   ^
           76|     concatStringsSep "\n" (map f (textClosureList predefined names));

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/activation/activation-script.nix:49:9:

           48|
           49|       ${textClosureMap id (withDrySnippets) (attrNames withDrySnippets)}
             |         ^
           50|

       … while evaluating 'systemActivationScript'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/activation/activation-script.nix:20:33:

           19|
           20|   systemActivationScript = set: onlyDry: let
             |                                 ^
           21|     set' = mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set;

       … from call site

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/activation/activation-script.nix:136:18:

          135|       apply = set: set // {
          136|         script = systemActivationScript set false;
             |                  ^
          137|       };

       … while evaluating the attribute 'system.activationScripts.script'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/nixos/modules/system/activation/activation-script.nix:136:9:

          135|       apply = set: set // {
          136|         script = systemActivationScript set false;
             |         ^
          137|       };

       … while evaluating the attribute 'activationScript' of the derivation 'nixos-system-nas-21.11.20211218.2627c4b'

       at /nix/store/idcl4krkhgqha859fdr1fgqgd4pda787-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let