refactor(nix): Use home-manager
Looks like nix-darwin is planning to drop per-user launchd (or perhaps per-user feature entirely).
This commit is contained in:
parent
dff532c060
commit
2ef4e6f407
4 changed files with 75 additions and 23 deletions
|
@ -49,23 +49,33 @@
|
|||
# Set Git commit hash for darwin-version.
|
||||
system.configurationRevision = vars.rev or null;
|
||||
|
||||
# Used for backwards compatibility, please read the changelog before changing.
|
||||
# $ darwin-rebuild changelog
|
||||
system.stateVersion = 4;
|
||||
|
||||
# The platform the configuration will be used on.
|
||||
nixpkgs.hostPlatform = vars.arch;
|
||||
|
||||
# Swap CapsLock with Esc for better vi-mode experience.
|
||||
launchd.user.agents.CapsEscSwap = {
|
||||
serviceConfig = {
|
||||
ProgramArguments = [
|
||||
"/usr/bin/hidutil"
|
||||
"property"
|
||||
"--set"
|
||||
"{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":0x700000039,\"HIDKeyboardModifierMappingDst\":0x700000029},{\"HIDKeyboardModifierMappingSrc\":0x700000029,\"HIDKeyboardModifierMappingDst\":0x700000039}]}"
|
||||
];
|
||||
RunAtLoad = true;
|
||||
# Used for backwards compatibility, please read the changelog before changing.
|
||||
# $ darwin-rebuild changelog
|
||||
system = {
|
||||
stateVersion = 4;
|
||||
};
|
||||
|
||||
users.users.ziro = {
|
||||
name = "ziro";
|
||||
home = "/Users/ziro";
|
||||
};
|
||||
home-manager.users.ziro = {
|
||||
home.stateVersion = "22.05";
|
||||
# Swap CapsLock with Esc for better vi-mode experience.
|
||||
launchd.agents.CapsEscSwap = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [
|
||||
"/usr/bin/hidutil"
|
||||
"property"
|
||||
"--set"
|
||||
"{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":0x700000039,\"HIDKeyboardModifierMappingDst\":0x700000029},{\"HIDKeyboardModifierMappingSrc\":0x700000029,\"HIDKeyboardModifierMappingDst\":0x700000039}]}"
|
||||
];
|
||||
RunAtLoad = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ inputs, nixpkgs, nix-darwin, vars, ... }:
|
||||
{ inputs, nixpkgs, nix-darwin, home-manager, vars, ... }:
|
||||
|
||||
let
|
||||
systemConfig = system: {
|
||||
|
@ -23,8 +23,15 @@ in
|
|||
in
|
||||
nix-darwin.lib.darwinSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs pkgs vars; };
|
||||
modules = [ ./configuration.nix ];
|
||||
specialArgs = { inherit inputs pkgs home-manager vars; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Imaginary M1, just for reference
|
||||
|
@ -35,8 +42,15 @@ in
|
|||
in
|
||||
nix-darwin.lib.darwinSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs pkgs vars; };
|
||||
modules = [ ./configuration.nix ];
|
||||
specialArgs = { inherit inputs pkgs home-manager vars; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
# vim:set ts=2 sw=2 et:
|
||||
|
|
22
.config/nix/flake.lock
generated
22
.config/nix/flake.lock
generated
|
@ -1,5 +1,26 @@
|
|||
{
|
||||
"nodes": {
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1720042825,
|
||||
"narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "release-24.05",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -38,6 +59,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"home-manager": "home-manager",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
|
|
|
@ -3,11 +3,17 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
|
||||
nix-darwin.url = "github:LnL7/nix-darwin";
|
||||
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nix-darwin = {
|
||||
url = "github:LnL7/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/release-24.05";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nix-darwin, nixpkgs }:
|
||||
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager }:
|
||||
let
|
||||
vars = {
|
||||
rev = self.rev or self.dirtyRev or null;
|
||||
|
@ -17,7 +23,7 @@
|
|||
darwinConfigurations = (
|
||||
import ./darwin {
|
||||
inherit (nixpkgs) lib;
|
||||
inherit inputs nixpkgs nix-darwin vars;
|
||||
inherit inputs nixpkgs nix-darwin home-manager vars;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue