Best way to pin a package to a certain revision within nixpkgs (flakes)

Howdy!

I am trying to use the swift package on my system which is defined using flakes. My problem is however that it does not seem as if swift is cached on the particular version of nixpkgs my system is pinned to (resulting in obscene build times!). What would be the best way to pin swift to a version that is cached, without holding back the rest of my system?

I imagine this will also be helpful when I start to build my development environments using flakes :slight_smile:

Thanks,
smkuehnhold

How does your inputs.nixpkgs.url looks like?

I normally use inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable", that’s the most close branch to master that is on cache.nixos.org

1 Like

flake.nix

inputs = {
  nixpkgs.url = "nixpkgs/21.11";
};

flake.lock

{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1638239011,
        "narHash": "sha256-AjhmbT4UBlJWqxY0ea8a6GU2C2HdKUREkG4
3oRr3TZg=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "ref": "21.11",
        "type": "indirect"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}