Skip to content

Instantly share code, notes, and snippets.

@noflcl
Created September 8, 2025 13:40
Show Gist options
  • Select an option

  • Save noflcl/2e86980b53af706efe5611cd2bc032bd to your computer and use it in GitHub Desktop.

Select an option

Save noflcl/2e86980b53af706efe5611cd2bc032bd to your computer and use it in GitHub Desktop.
Pinning software with Nix home-manager

Pinning home-manager Packages

Are you using home-manager to install and configure software? Do you have a need to pin specific software versions?

First step is to select the build version of the software. You can go directly to GitHub or any site that distributes the archive of the build. I typically use https://lazamar.co.uk/nix-versions/?channel=nixos-25.05 to search for package URLs. Once you identify the build version you require, use nix-prefetch-url --type sha256 to retrieve and hash the software package.

{ pkgs, ... }:

let

  # Pinned v:1.101.0 VS Code
  # nix-prefetch-url --type sha256 https://github.com/NixOS/nixpkgs/archive/1c1c9b3f5ec0421eaa0f22746295466ee6a8d48f.tar.gz
  pinnedVSCode = import (fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/1c1c9b3f5ec0421eaa0f22746295466ee6a8d48f.tar.gz";
    sha256 = "0szvq1swpzyjmyyw929ngxy1khdnd9ba96qds2bm6l6kg4iq3cq0";
  }) {
      system = pkgs.stdenv.hostPlatform.system;
      config = { allowUnfree = true; };
     };

  # nix-prefetch-url --type sha256 https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot/1.342.0/vspackage
  copilot.backdate = pkgs.vscode-utils.extensionFromVscodeMarketplace {
    name = "copilot";
    publisher = "github";
    version = "1.342.0";
    sha256 = "0kl1qkp47270g9rj9dmm297ydr2xzfp80wsbjdcd623wm1022p7k";
  };

  # nix-prefetch-url --type sha256 https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot-chat/0.28.5/vspackage
  copilot.chat.backdate = pkgs.vscode-utils.extensionFromVscodeMarketplace {
    name = "copilot-chat";
    publisher = "github";
    version = "0.28.5";
    sha256 = "0wgr7bdn22l7r5qkxkr45nxqg234132qk6i4sd9qas1ihn8f45mk";
  };

in

{
  programs.vscode = {
    enable = true;
    package = pinnedVSCode.vscode;
    profiles.default.extensions = with pkgs.vscode-extensions; [
      # github.copilot
      # github.copilot-chat
      copilot.backdate
      copilot.chat.backdate
    ];
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment