Skip to content

Accessing flakes from inside home-manager modules #1698

Description

@andyrichardson

Issue description

Hi there! First off, thanks for the awesome library!

I'm currently trying to use flakes with home manager - however, I'm struggling to access a flake (output argument) in a home-manager module.

Example

Here's an example nix config

flake.nix

{
  description = "NixOS configuration";
  inputs = {
    # Some flake I want to access in a home-manager module
    desiredflake = {
      url = "github:zsh-users/antigen/v2.2.3";
      flake = false;
    };
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    darwin.url = "github:lnl7/nix-darwin/master";
    darwin.inputs.nixpkgs.follows = "nixpkgs";
    home-manager.url = "github:nix-community/home-manager";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };
  

  outputs = { desiredflake, home-manager, nixpkgs, darwin, ... }: {
    defaultPackage.x86_64-darwin = (darwin.lib.darwinSystem {
      inputs = { inherit home-manager nixpkgs darwin desiredflake; };
      modules = [ 
        home-manager.darwinModules.home-manager
        {
          home-manager.useUserPackages = true;
          home-manager.users.someuser = import ./home.nix;
        }
      ];
    }).system;
  };
}

home.nix

{ pkgs, ... }:

{
  programs.zsh = {
    enable = true;
    plugins = [
      {
        name = "zsh-nix-shell";
        file = "antigen.zsh";
        src = desiredflake; # How does this flake output get to this module?
      }
    ];
  };
}

Notes

  • It looks like home-manager doesn't forward output arguments of a flake to modules
  • I'm not sure if there is a way to access a flake without having it passed explicitly (e.g. builtins.getFlakeOutput desiredflake)

Meta

Maintainer CC

Technical details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions