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.
|
# Set Git commit hash for darwin-version.
|
||||||
system.configurationRevision = vars.rev or null;
|
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.
|
# The platform the configuration will be used on.
|
||||||
nixpkgs.hostPlatform = vars.arch;
|
nixpkgs.hostPlatform = vars.arch;
|
||||||
|
|
||||||
# Swap CapsLock with Esc for better vi-mode experience.
|
# Used for backwards compatibility, please read the changelog before changing.
|
||||||
launchd.user.agents.CapsEscSwap = {
|
# $ darwin-rebuild changelog
|
||||||
serviceConfig = {
|
system = {
|
||||||
ProgramArguments = [
|
stateVersion = 4;
|
||||||
"/usr/bin/hidutil"
|
};
|
||||||
"property"
|
|
||||||
"--set"
|
users.users.ziro = {
|
||||||
"{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":0x700000039,\"HIDKeyboardModifierMappingDst\":0x700000029},{\"HIDKeyboardModifierMappingSrc\":0x700000029,\"HIDKeyboardModifierMappingDst\":0x700000039}]}"
|
name = "ziro";
|
||||||
];
|
home = "/Users/ziro";
|
||||||
RunAtLoad = true;
|
};
|
||||||
|
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
|
let
|
||||||
systemConfig = system: {
|
systemConfig = system: {
|
||||||
|
@ -23,8 +23,15 @@ in
|
||||||
in
|
in
|
||||||
nix-darwin.lib.darwinSystem {
|
nix-darwin.lib.darwinSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = { inherit inputs pkgs vars; };
|
specialArgs = { inherit inputs pkgs home-manager vars; };
|
||||||
modules = [ ./configuration.nix ];
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
home-manager.darwinModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Imaginary M1, just for reference
|
# Imaginary M1, just for reference
|
||||||
|
@ -35,8 +42,15 @@ in
|
||||||
in
|
in
|
||||||
nix-darwin.lib.darwinSystem {
|
nix-darwin.lib.darwinSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = { inherit inputs pkgs vars; };
|
specialArgs = { inherit inputs pkgs home-manager vars; };
|
||||||
modules = [ ./configuration.nix ];
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
home-manager.darwinModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
# vim:set ts=2 sw=2 et:
|
# vim:set ts=2 sw=2 et:
|
||||||
|
|
22
.config/nix/flake.lock
generated
22
.config/nix/flake.lock
generated
|
@ -1,5 +1,26 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"nix-darwin": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
@ -38,6 +59,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"home-manager": "home-manager",
|
||||||
"nix-darwin": "nix-darwin",
|
"nix-darwin": "nix-darwin",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,17 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
|
||||||
nix-darwin.url = "github:LnL7/nix-darwin";
|
nix-darwin = {
|
||||||
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
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
|
let
|
||||||
vars = {
|
vars = {
|
||||||
rev = self.rev or self.dirtyRev or null;
|
rev = self.rev or self.dirtyRev or null;
|
||||||
|
@ -17,7 +23,7 @@
|
||||||
darwinConfigurations = (
|
darwinConfigurations = (
|
||||||
import ./darwin {
|
import ./darwin {
|
||||||
inherit (nixpkgs) lib;
|
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