home-manager

This commit is contained in:
Madeleine Sydney
2024-12-28 21:44:51 -07:00
parent 9a99a6dfb7
commit 56f2a65be2
9 changed files with 83 additions and 40 deletions

26
flake.lock generated
View File

@@ -20,9 +20,7 @@
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1731235328,
@@ -57,7 +55,7 @@
"inputs": {
"niri-stable": "niri-stable",
"niri-unstable": "niri-unstable",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs_3",
"nixpkgs-stable": "nixpkgs-stable",
"xwayland-satellite-stable": "xwayland-satellite-stable",
"xwayland-satellite-unstable": "xwayland-satellite-unstable"
@@ -142,6 +140,22 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735291276,
"narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "634fd46801442d760e09493a794c4f15db2d0cbb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1734119587,
"narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
@@ -157,7 +171,7 @@
"type": "github"
}
},
"nixpkgs_3": {
"nixpkgs_4": {
"locked": {
"lastModified": 1731245184,
"narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=",
@@ -179,7 +193,7 @@
"home-manager": "home-manager",
"impermanence": "impermanence",
"niri": "niri",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs_4"
}
},
"xwayland-satellite-stable": {

View File

@@ -8,15 +8,13 @@
impermanence.url = "github:nix-community/impermanence";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager.url = "github:nix-community/home-manager";
niri.url = "github:sodiboo/niri-flake";
};
outputs = { nixpkgs, ... }@inputs:
# TODO: Move to utils.nix.
let list-nix-directory = dir:
builtins.attrNames
(nixpkgs.lib.filterAttrs
@@ -58,7 +56,7 @@
({ config, lib, ... }: {
users.users =
(lib.mapAttrs
(k: v: (import ./users/${k}).systemUser)
(k: v: (import ./users/${k}).systemConfiguration)
(lib.filterAttrs
(k: _v: builtins.elem k config.sydnix.users.users)
(builtins.readDir ./users)));
@@ -85,14 +83,19 @@
inputs.home-manager.nixosModules.home-manager
({ config, lib, self, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# home-manager.useUserPackages = true;
home-manager.users =
lib.filterAttrs
(k: _v: builtins.elem k config.sydnix.users.users)
self.homeConfigurations;
home-manager.extraSpecialArgs = inputs // { inherit self; };
home-manager.extraSpecialArgs = {
utils = import ./lib/utils.nix {
inherit config lib;
pkgs = nixpkgs;
};
};
})
];
};
@@ -103,9 +106,10 @@
homeConfigurations =
let users = builtins.readDir ./users;
mkUser = username: _v: {
# TODO: This is very ad-hoc, and I don't like it. Organise this better.
# TODO: This is very ad-hoc, and I don't like it. Organise this
# better.
imports = [
(import ./users/${username}).home
(import ./users/${username}/default.nix).homeConfiguration
inputs.self.homeManagerModules.default

View File

@@ -46,6 +46,21 @@
};
};
# HACK: This is here temporarily so I can use `/persist` without
# Impermanence. This can be removed once impermanence is enabled.
systemd.tmpfiles.settings = {
"10-persist" = {
# Permit members of `cfg.persistGroupName` to read, write, and execute
# /persist.
"/persist" = {
z = {
group = "persist";
mode = "2775";
};
};
};
};
# networking.hostName = "nixos-testbed";
networking.hostId = "238e9b1e"; # head -c 8 /etc/machine-id

13
lib/utils.nix Normal file
View File

@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
mkMutableSymlink =
relativePath:
lib.mkMutableSymlink (config.sydnix.configDir + relativePath);
listNixFilesInDirectory = dir:
builtins.attrNames
(pkgs.lib.filterAttrs
(k: _v: pkgs.lib.hasSuffix ".nix" k)
(builtins.readDir dir));
}

View File

@@ -1,32 +1,13 @@
{
systemUser = {
systemConfiguration = {
isNormalUser = true;
extraGroups = [ "wheel" "persist" ];
# Change this immediately after installation!
initialPassword = "password123";
};
home = { config, lib, pkgs, ... }: {
sydnix.impermanence = {
enable = false;
directories = [
# ".ssh"
# ".config/systemd"
];
mutableDotfiles = {
enable = false;
# files = [
# "nvim/.config/nvim/init.vim"
# "nvim/.vimrc"
# ];
# directories = [
# "qtile"
# ];
};
};
homeConfiguration = { config, lib, pkgs, ... }: {
imports = [ ./programs.nix ];
home = {
stateVersion = "18.09";
packages = [

View File

@@ -1 +0,0 @@
so ~/.vimrc

View File

@@ -1,2 +0,0 @@
imap jk <ESC>
xmap JK <ESC>

7
users/crumb/programs.nix Normal file
View File

@@ -0,0 +1,7 @@
{ config, lib, pkgs, utils, ... }:
{
imports =
map (x: ./programs/${x})
(utils.listNixFilesInDirectory ./programs);
}

View File

@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
home.file.".vimrc".text = ''
imap jk <ESC>
xmap JK <ESC>
'';
xdg.configFile."nvim/init.vim".text = ''
so ~/.vimrc
'';
}