-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Prepare inclusion in nixos-search #2971
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/flake.lock | ||
/result* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# This module is the common base for the NixOS and nix-darwin modules. | ||
ncfavier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# For OS-specific configuration, please edit nixos/default.nix or nix-darwin/default.nix instead. | ||
|
||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
|
||
cfg = config.home-manager; | ||
|
||
extendedLib = import ./modules/lib/stdlib-extended.nix pkgs.lib; | ||
|
||
hmModule' = types.submoduleWith { | ||
specialArgs = { | ||
lib = extendedLib; | ||
osConfig = config; | ||
modulesPath = builtins.toString ./modules; | ||
} // cfg.extraSpecialArgs; | ||
modules = [ | ||
({ name, ... }: { | ||
imports = import ./modules/modules.nix { | ||
inherit pkgs; | ||
lib = extendedLib; | ||
useNixpkgsModule = !cfg.useGlobalPkgs; | ||
}; | ||
|
||
config = { | ||
submoduleSupport.enable = true; | ||
submoduleSupport.externalPackageInstall = cfg.useUserPackages; | ||
|
||
home.username = config.users.users.${name}.name; | ||
home.homeDirectory = config.users.users.${name}.home; | ||
|
||
# Make activation script use same version of Nix as system as a whole. | ||
# This avoids problems with Nix not being in PATH. | ||
home.extraActivationPath = [ config.nix.package ]; | ||
}; | ||
}) | ||
] ++ cfg.sharedModules; | ||
} // { | ||
description = "Home Manager module"; | ||
}; | ||
|
||
# TODO: hack until https://github.com/NixOS/nixpkgs/pull/173621 lands | ||
hmModule = hmModule' // { | ||
substSubModules = m: | ||
hmModule'.substSubModules m // { | ||
inherit (hmModule') description; | ||
}; | ||
}; | ||
|
||
in { | ||
options.home-manager = { | ||
useUserPackages = mkEnableOption '' | ||
installation of user packages through the | ||
<option>users.users.<name>.packages</option> option | ||
''; | ||
|
||
useGlobalPkgs = mkEnableOption '' | ||
using the system configuration's <literal>pkgs</literal> | ||
argument in Home Manager. This disables the Home Manager | ||
options <option>nixpkgs.*</option> | ||
''; | ||
|
||
backupFileExtension = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
example = "backup"; | ||
description = '' | ||
On activation move existing files by appending the given | ||
file extension rather than exiting with an error. | ||
''; | ||
}; | ||
|
||
extraSpecialArgs = mkOption { | ||
type = types.attrs; | ||
default = { }; | ||
example = literalExpression "{ inherit emacs-overlay; }"; | ||
description = '' | ||
Extra <literal>specialArgs</literal> passed to Home Manager. This | ||
option can be used to pass additional arguments to all modules. | ||
''; | ||
}; | ||
|
||
sharedModules = mkOption { | ||
type = with types; listOf raw; | ||
default = [ ]; | ||
example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]"; | ||
description = '' | ||
Extra modules added to all users. | ||
''; | ||
}; | ||
|
||
verbose = mkEnableOption "verbose output on activation"; | ||
|
||
users = mkOption { | ||
type = types.attrsOf hmModule; | ||
default = { }; | ||
# Prevent the entire submodule being included in the documentation. | ||
visible = "shallow"; | ||
description = '' | ||
Per-user Home Manager configuration. | ||
''; | ||
}; | ||
}; | ||
|
||
config = mkIf (cfg.users != { }) { | ||
warnings = flatten (flip mapAttrsToList cfg.users (user: config: | ||
flip map config.warnings (warning: "${user} profile: ${warning}"))); | ||
|
||
assertions = flatten (flip mapAttrsToList cfg.users (user: config: | ||
flip map config.assertions (assertion: { | ||
inherit (assertion) assertion; | ||
message = "${user} profile: ${assertion.message}"; | ||
}))); | ||
|
||
users.users = mkIf cfg.useUserPackages | ||
(mapAttrs (username: usercfg: { packages = [ usercfg.home.path ]; }) | ||
cfg.users); | ||
|
||
environment.pathsToLink = mkIf cfg.useUserPackages [ "/etc/profile.d" ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels pretty ugly to me. Why not simply change the
pkgs.fetchFromGitLab
tofetchTarball
when fetching nmd and nmt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a compatibility layer that should progressively become useless as we transition to flakes and the new nix CLI.
We could, but if we're going to use flakes, we might as well use them fully, i.e. for all inputs. I think they're a nicer way to manage dependencies, and they make updating and overriding easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that eventually it will be worth switching over to flakes but I'm skeptical about delving too deep while the feature is marked as experimental. At least unless there is a really compelling reason. But in this case there is a straight forward way to avoid the pkgs reference without touching flakes and needing compatibility shims.
I also would like to move the nmt and nmd projects over to sourcehut at some point and it doesn't seem like the flake-compat project supports the sourcehut URLs. I'll probably maintain a mirror at the gitlab location so this is not a blocker, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also not a blocker because we can just use URLs like
git+https://git.sr.ht/~rycee/nmt
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is only marked as experimental to not have to create backwards compatibility while it still might change.