Stream: nix

Topic: Overriding flake inputs from CLI


view this post on Zulip Pratham Patel (Jun 05 2024 at 14:52):

I looked and there doesn't seem to be a straightforward way to override flake inputs from the CLI. But I was wondering what method(s) you have employed to do so? I'm looking for opinions on how to do this with minimal changes.

At the moment, I have this:

  inputs = {
    nixpkgs-1stable.url = "github:NixOS/nixpkgs/nixos-24.05";
    home-manager-1stable.url = "github:nix-community/home-manager/release-24.05";
    home-manager-1stable.inputs.nixpkgs.follows = "nixpkgs-1stable";

    nixpkgs-1stable-small.url = "github:NixOS/nixpkgs/nixos-24.05-small";
    home-manager-1stable-small.url = "github:nix-community/home-manager/release-24.05";
    home-manager-1stable-small.inputs.nixpkgs.follows = "nixpkgs-1stable-small";

    nixpkgs-0unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager-0unstable.url = "github:nix-community/home-manager/master";
    home-manager-0unstable.inputs.nixpkgs.follows = "nixpkgs-0unstable";

    nixpkgs-0unstable-small.url = "github:NixOS/nixpkgs/nixos-unstable-small";
    home-manager-0unstable-small.url = "github:nix-community/home-manager/master";
    home-manager-0unstable-small.inputs.nixpkgs.follows = "nixpkgs-0unstable-small";
  };

  outputs = { self,
    nixpkgs-1stable,         home-manager-1stable,
    nixpkgs-1stable-small,   home-manager-1stable-small,
    nixpkgs-0unstable,       home-manager-0unstable,
    nixpkgs-0unstable-small, home-manager-0unstable-small,
    ... }:
    let
      nixpkgsRelease = "24.05";
      nixpkgs = nixpkgs-1stable;
      home-manager = home-manager-1stable;
      #nixpkgs = nixpkgs-1stable-small;
      #home-manager = home-manager-1stable-small;
      #nixpkgs = nixpkgs-0unstable;
      #home-manager = home-manager-0unstable;
      #nixpkgs = nixpkgs-0unstable-small;
      #home-manager = home-manager-0unstable-small;

# --- [ snip ] ---

I don't see a "clean" way (tbh, I don't see _any way_ lol) to override nixpkgs to be, say, nixpkgs-0unstable-small from the CLI without a tech-debt of changes.

view this post on Zulip Pratham Patel (Jun 05 2024 at 14:54):

Had inputs not been "static", I could have provided nixos-unstable-small for nixpkgs and master for home-manager's channels respectively. But alas, I'm stuck here :)

view this post on Zulip Pratham Patel (Jun 05 2024 at 14:55):

("Static" as in a let..in block in inputs such that I could use github:NixOS/nixpkgs/${nixpkgsChannel}.)

view this post on Zulip Srid (Jun 05 2024 at 15:04):

--override-input?

view this post on Zulip Pratham Patel (Jun 05 2024 at 16:09):

Oh wow, that worked. I should read the manual instead of user comments :sweat_smile:
Thank you @Srid

view this post on Zulip Srid (Jun 05 2024 at 17:12):

@Pratham Patel By the way, is what you are trying to do here similar to this request?

view this post on Zulip Pratham Patel (Jun 05 2024 at 17:32):

Kind of. I want to use a different channel of nixpkgs/home-manager to test if the the future (nixos-unstable/master) branches introduce a breaking change or not. This runs in a local CI server I have at my home. :)


Last updated: Nov 15 2024 at 12:33 UTC