Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken NIX_PATH workaround #73

Merged
merged 1 commit into from
May 2, 2024

Conversation

JManch
Copy link
Contributor

@JManch JManch commented May 1, 2024

Commit 8204a49 disables channels which breaks NIX_PATH functionality due to NixOS/nix#9574.

This adds a workaround.

@mobsenpai
Copy link

mobsenpai commented May 1, 2024

Does this issue occur due to disabling channel or it is some issue on the nixos's part?

@Misterio77
Copy link
Owner

Thanks!

@Misterio77 Misterio77 merged commit f1ecf7e into Misterio77:main May 2, 2024
@JManch JManch deleted the nix-path-workaround branch May 2, 2024 21:21
@mobsenpai
Copy link

mobsenpai commented May 2, 2024

It's a problem with the Nix command line tool

OMG gotcha!

@JManch I want to ask one thing, why do we need to specially set nix shell, nix profile or nix-env to use flake inputs nixpkgs version? Shouldn't it be by default? Is there any issue tracking of this or will it be implemented to do that by default or will it not?

This whole code is for that right?

nix = let
    flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
  in {
    settings = {
      # Enable flakes and new 'nix' command
      experimental-features = "nix-command flakes";
      # Opinionated: disable global registry
      flake-registry = "";
      # Workaround for https://github.com/NixOS/nix/issues/9574
      nix-path = config.nix.nixPath;
    };
    # Opinionated: disable channels
    channel.enable = false;
    # Opinionated: make flake registry and nix path match flake inputs
    registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs;
    nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
  };

I use 23.11 nixpkgs version and without adding the above code nix shell by default uses unstable branch.

@mobsenpai
Copy link

What really? Then what is the use of the above mentioned code? Also I will do nix flake update and mention if it works or not afterwards.

@mobsenpai
Copy link

mobsenpai commented May 2, 2024

@JManch Okay so I did nix flake update and I can still see the same thing.

    "nixpkgs": {
      "locked": {
        "lastModified": 1712963716,
        "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1712963716,
        "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_3": {
      "locked": {
        "lastModified": 1714531828,
        "narHash": "sha256-ILsf3bdY/hNNI/Hu5bSt2/KbmHaAVhBbNUOdGztTHEg=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "0638fe2715d998fa81d173aad264eb671ce2ebc1",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-23.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },

Can you give me some hint. I have no idea how to do it.
what I am doing is I have set 23.11 in flake.nix and then trying to install some package lets say "appflowy"
in 23.11 the app version is 0.3.8 but in unstable it is 0.5.5.
I do nix shell nixpkgs#appflowy and it starts fetching nixpkgs-unstable branch and downloads the unstable version.

I can also see this if I abort the command using ctrl + c

error:
       … while fetching the input 'github:NixOS/nixpkgs/nixpkgs-unstable'

       error: download of 'https://github.com/NixOS/nixpkgs/archive/1c74cc292b61614e74c1cf0d372f79d57fb4936b.tar.gz' was interrupted

@mobsenpai
Copy link

@JManch I added those and all the unstable words from flake.lock is gone. But still nix shell nixpkgs#packageName is using unstable branch. I should also mention that I removed this code, as you said it is already default to use the defined nixpkgs.
Flake.lock ->

{
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1714043624,
        "narHash": "sha256-Xn2r0Jv95TswvPlvamCC46wwNo8ALjRCMBJbGykdhcM=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "86853e31dc1b62c6eeed11c667e8cdd0285d4411",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-23.11",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "hypridle": {
      "inputs": {
        "hyprlang": "hyprlang",
        "nixpkgs": [
          "nixpkgs"
        ],
        "systems": "systems_2"
      },
      "locked": {
        "lastModified": 1713472482,
        "narHash": "sha256-7Ft5WZTMIjXOGgRCf31DZBwK6RK8xkeKlD5vFXz3gII=",
        "owner": "hyprwm",
        "repo": "hypridle",
        "rev": "7cff4581a3753154fc5b41f39a098fad49b777b1",
        "type": "github"
      },
      "original": {
        "owner": "hyprwm",
        "repo": "hypridle",
        "type": "github"
      }
    },
    "hyprlang": {
      "inputs": {
        "nixpkgs": [
          "hypridle",
          "nixpkgs"
        ],
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1713121246,
        "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=",
        "owner": "hyprwm",
        "repo": "hyprlang",
        "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706",
        "type": "github"
      },
      "original": {
        "owner": "hyprwm",
        "repo": "hyprlang",
        "type": "github"
      }
    },
    "hyprlang_2": {
      "inputs": {
        "nixpkgs": [
          "hyprlock",
          "nixpkgs"
        ],
        "systems": "systems_3"
      },
      "locked": {
        "lastModified": 1713121246,
        "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=",
        "owner": "hyprwm",
        "repo": "hyprlang",
        "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706",
        "type": "github"
      },
      "original": {
        "owner": "hyprwm",
        "repo": "hyprlang",
        "type": "github"
      }
    },
    "hyprlock": {
      "inputs": {
        "hyprlang": "hyprlang_2",
        "nixpkgs": [
          "nixpkgs"
        ],
        "systems": "systems_4"
      },
      "locked": {
        "lastModified": 1714659497,
        "narHash": "sha256-CJH9xc2y0AU+2GQSg2dubcPep/iIwb5f/cr2+0LGBWY=",
        "owner": "hyprwm",
        "repo": "hyprlock",
        "rev": "9cca0dbb45941e13322ff95796f486676f061c6e",
        "type": "github"
      },
      "original": {
        "owner": "hyprwm",
        "repo": "hyprlock",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1714531828,
        "narHash": "sha256-ILsf3bdY/hNNI/Hu5bSt2/KbmHaAVhBbNUOdGztTHEg=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "0638fe2715d998fa81d173aad264eb671ce2ebc1",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-23.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nur": {
      "locked": {
        "lastModified": 1714681542,
        "narHash": "sha256-7WQo+TMORkw/Bo1AADX7IuYu28rWVJN7qMTq3QDWU9E=",
        "owner": "nix-community",
        "repo": "NUR",
        "rev": "6132349be4a6cfe62cfe744d622a645e4981d458",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "NUR",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "hypridle": "hypridle",
        "hyprlock": "hyprlock",
        "nixpkgs": "nixpkgs",
        "nur": "nur"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1689347949,
        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
        "owner": "nix-systems",
        "repo": "default-linux",
        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default-linux",
        "type": "github"
      }
    },
    "systems_2": {
      "locked": {
        "lastModified": 1689347949,
        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
        "owner": "nix-systems",
        "repo": "default-linux",
        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default-linux",
        "type": "github"
      }
    },
    "systems_3": {
      "locked": {
        "lastModified": 1689347949,
        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
        "owner": "nix-systems",
        "repo": "default-linux",
        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default-linux",
        "type": "github"
      }
    },
    "systems_4": {
      "locked": {
        "lastModified": 1689347949,
        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
        "owner": "nix-systems",
        "repo": "default-linux",
        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default-linux",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

@mobsenpai
Copy link

mobsenpai commented May 3, 2024

@JManch,
Yeah I only removed the registry part.

  • This is in the /etc/nix/registry.json ->
{"flakes":[],"version":2}
  • Output of nix registry list ->
global flake:agda github:agda/agda
global flake:arion github:hercules-ci/arion
global flake:blender-bin github:edolstra/nix-warez?dir=blender
global flake:bundlers github:NixOS/bundlers
global flake:cachix github:cachix/cachix
global flake:composable github:ComposableFi/composable
global flake:disko github:nix-community/disko
global flake:dreampkgs github:nix-community/dreampkgs
global flake:dwarffs github:edolstra/dwarffs
global flake:emacs-overlay github:nix-community/emacs-overlay
global flake:fenix github:nix-community/fenix
global flake:flake-parts github:hercules-ci/flake-parts
global flake:flake-utils github:numtide/flake-utils
global flake:gemini github:nix-community/flake-gemini
global flake:helix github:helix-editor/helix
global flake:hercules-ci-agent github:hercules-ci/hercules-ci-agent
global flake:hercules-ci-effects github:hercules-ci/hercules-ci-effects
global flake:home-manager github:nix-community/home-manager
global flake:hydra github:NixOS/hydra
global flake:mach-nix github:DavHau/mach-nix
global flake:nickel github:tweag/nickel
global flake:nimble github:nix-community/flake-nimble
global flake:nix github:NixOS/nix
global flake:nix-darwin github:LnL7/nix-darwin
global flake:nix-serve github:edolstra/nix-serve
global flake:nixops github:NixOS/nixops
global flake:nixos-hardware github:NixOS/nixos-hardware
global flake:nixos-homepage github:NixOS/nixos-homepage
global flake:nixos-search github:NixOS/nixos-search
global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable
global flake:nur github:nix-community/NUR
global flake:patchelf github:NixOS/patchelf
global flake:poetry2nix github:nix-community/poetry2nix
global flake:pridefetch github:SpyHoodle/pridefetch
global flake:sops-nix github:Mic92/sops-nix
global flake:systems github:nix-systems/default
global flake:templates github:NixOS/templates
  • There is no such file ~/.config/nix/registry.json
  • There is also a lemmy post I made and there was this comment

@mobsenpai
Copy link

mobsenpai commented May 3, 2024

@JManch Yeah that nix.registry.nixpkgs.flake = inputs.nixpkgs; did the job. But now I am super curious as to what is happening with my system, with question like, Should I add this line permanently of will a reinstall should fix it?, how did it even happen? why it worked before when I was adding registry and nixpath settings, etc etc

@mobsenpai
Copy link

mobsenpai commented May 3, 2024

Thank god it wasn't a me issue. It's okay I have anyway added the misterio's nix registry and nixpath settings and that seem to work well, as now I can use both stable and unstable when doing nix shell, plus it solved the registry problem as well. And in the first I thought that it was only causing errors like what happened in this NIX_PATH issue, so I wanted to not use it but that turned out to be a nixos's underlining issue. Just hope that this issue gets solved so that I can remove nix-path = config.nix.nixPath; this workaround. At the end I have no one to blame to, just have thanks for @JManch for sticking around for what 2 days now. Thank you so much!

@arthsmn
Copy link

arthsmn commented Sep 8, 2024

Now that NixOS/nix#11079 is merged should the workaround be removed?

@JManch
Copy link
Contributor Author

JManch commented Sep 9, 2024

Not yet, Nixpkgs still uses Nix 2.18.5 and the fix hasn't been backported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants