Convert home-manager to flakes
Instead of calling the home manager directly in the user's list, we add a command for the user to invoke "hms" and have their environment setup in the way that Greg likes.
This commit is contained in:
Generated
+5
-5
@@ -87,13 +87,13 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nur": {
|
||||
"nurpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1654123271,
|
||||
"narHash": "sha256-xM85/VFYu8I8jZiZ7U0CmZO/98sHO7+f7PIMxQVZXCM=",
|
||||
"lastModified": 1659413279,
|
||||
"narHash": "sha256-7tCR//2NnB1Xw2AqK0RTYJH9YcAEKHmhiSAYsBbQp8s=",
|
||||
"owner": "nix-community",
|
||||
"repo": "NUR",
|
||||
"rev": "4c83235ccca7cfcf34fee9f49023f21c0e9db128",
|
||||
"rev": "9bedf12848954098f5298215b3a06b5eb2983058",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -108,7 +108,7 @@
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixunstable": "nixunstable",
|
||||
"nur": "nur"
|
||||
"nurpkgs": "nurpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
url = "github:nix-community/home-manager/release-22.05";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nur.url = "github:nix-community/NUR";
|
||||
nurpkgs.url = "github:nix-community/NUR";
|
||||
};
|
||||
|
||||
outputs = {nixpkgs, nixunstable, agenix, home-manager, nur, self}@inputs:
|
||||
outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self}@inputs:
|
||||
let
|
||||
local_overlay = import ./overlays;
|
||||
|
||||
mods = hostname: [
|
||||
{ nixpkgs.overlays = [ nur.overlay local_overlay ]; }
|
||||
{ nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; }
|
||||
agenix.nixosModule
|
||||
./modules
|
||||
./profiles/base
|
||||
@@ -28,8 +28,6 @@
|
||||
home-manager.nixosModules.home-manager {
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.greg = import ./home/home.nix "greg";
|
||||
home-manager.users.root = import ./home/home.nix "root";
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit nixunstable;
|
||||
};
|
||||
@@ -54,5 +52,11 @@
|
||||
};
|
||||
|
||||
defaultPackage."x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage;
|
||||
|
||||
homeConfigurations = (
|
||||
import ./home {
|
||||
inherit nixpkgs nixunstable agenix home-manager nurpkgs;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
{ nixpkgs, nurpkgs, home-manager, username ? builtins.getEnv "USER", ... }:
|
||||
|
||||
let
|
||||
homeDirectory = if username == "root" then "/root" else "/home/${username}";
|
||||
configDir = "${homeDirectory}/.config";
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
config.allowUnfree = true;
|
||||
config.xdg.configHome = configDir;
|
||||
overlays = [
|
||||
nurpkgs.overlay
|
||||
(import ../overlays)
|
||||
];
|
||||
};
|
||||
|
||||
nur = import nurpkgs {
|
||||
inherit pkgs;
|
||||
nur = pkgs;
|
||||
};
|
||||
|
||||
mkhome = system: gui:
|
||||
home-manager.lib.homeManagerConfiguration rec {
|
||||
inherit pkgs system username homeDirectory;
|
||||
stateVersion = "22.05";
|
||||
configuration = import ./home.nix username {
|
||||
inherit nur pkgs gui;
|
||||
inherit (pkgs) config lib stdenv;
|
||||
};
|
||||
};
|
||||
in {
|
||||
"aarch64-gui" = mkhome "aarch64-linux" true;
|
||||
"aarch64-nogui" = mkhome "aarch64-linux" false;
|
||||
"x86_64-gui" = mkhome "x86_64-linux" true;
|
||||
"x86_64-nogui" = mkhome "x86_64-linux" false;
|
||||
}
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
name: { pkgs, lib, nixosConfig, ...}:
|
||||
name: { pkgs, lib, gui, ...}:
|
||||
|
||||
let
|
||||
guiImports = if nixosConfig.greg.gnome.enable then
|
||||
guiImports = if gui then
|
||||
[ ./gui ] else [];
|
||||
|
||||
in {
|
||||
@@ -17,7 +17,8 @@ in {
|
||||
] ++ guiImports;
|
||||
|
||||
|
||||
home.username = name;
|
||||
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
||||
home.stateVersion = "21.11";
|
||||
home.stateVersion = "22.05";
|
||||
home.packages = [
|
||||
pkgs.hms
|
||||
];
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,8 +1,6 @@
|
||||
{ pkgs, config, nixosConfig, lib, ... }:
|
||||
{ pkgs, config, lib, ... }:
|
||||
|
||||
let
|
||||
enable = nixosConfig.greg.gnome.enable;
|
||||
in {
|
||||
{
|
||||
programs.xonsh = {
|
||||
enable = true;
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
# Use the systemd-boot EFI boot loader.
|
||||
#boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.grub.device = "/dev/nvme0n1";
|
||||
boot.loader.grub.useOSProber = true;
|
||||
boot.loader.grub.extraEntries = ''
|
||||
menuentry "Windows" {
|
||||
chainloader (hd0,2)+1
|
||||
}
|
||||
'';
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
networking.interfaces.enp4s0.useDHCP = true;
|
||||
}
|
||||
|
||||
@@ -8,4 +8,8 @@ self: super:
|
||||
xonsh = super.xonsh.overridePythonAttrs (old: rec{
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ];
|
||||
});
|
||||
|
||||
hms = super.callPackage ./hms.nix {
|
||||
pkgs = self.pkgs;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellScriptBin "hms" ''
|
||||
set -eo pipefail
|
||||
# Build different targets with GUI or not
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
target="nogui"
|
||||
else
|
||||
target="gui"
|
||||
fi
|
||||
|
||||
# Build and switch
|
||||
echo "Building $(uname -m)-$target"
|
||||
dest=$(mktemp -d)
|
||||
pushd "$dest" > /dev/null
|
||||
nix build --impure /etc/nixos#homeConfigurations.$(uname -m)-$target.activationPackage
|
||||
./result/activate
|
||||
popd > /dev/null
|
||||
rm -r "$dest"
|
||||
''
|
||||
@@ -27,6 +27,13 @@
|
||||
];
|
||||
};
|
||||
|
||||
users.users.test = {
|
||||
isNormalUser = true;
|
||||
createHome = true;
|
||||
extraGroups = [ ];
|
||||
shell = pkgs.xonsh;
|
||||
};
|
||||
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
console = {
|
||||
|
||||
@@ -15,6 +15,7 @@ in {
|
||||
git
|
||||
gnupatch
|
||||
findutils
|
||||
hms # My own home manager switcher
|
||||
home-manager
|
||||
htop
|
||||
myPython
|
||||
|
||||
Reference in New Issue
Block a user