Add initial installer

This commit is contained in:
2022-02-17 15:47:24 +00:00
parent 788e476c01
commit c0414cd062
15 changed files with 169 additions and 87 deletions

View File

@@ -0,0 +1,9 @@
{ pkgs, ... }:
{
# So home-manager will inject the sourcing of ~/.nix-profile/etc/profile.d/nix.sh
targets.genericLinux.enable = true;
programs = {
kakoune.enable = true;
};
}

51
home-manager/default.nix Normal file
View File

@@ -0,0 +1,51 @@
{ lib, hmFlakes, inputs, pkgs', modules }:
let
inherit (builtins) removeAttrs mapAttrs;
inherit (lib) flatten optional recursiveUpdate;
inherit (lib.my) homeStateVersion;
mkHome = name: {
system,
nixpkgs ? "unstable",
home-manager ? nixpkgs,
config,
...
}@args:
let
rest = removeAttrs args [ "nixpkgs" "home-manager" "config" ];
in
# homeManagerConfiguration doesn't allow us to set lib directly (inherits from passed pkgs)
hmFlakes.${home-manager}.lib.homeManagerConfiguration (recursiveUpdate rest {
configuration = config;
# Passing pkgs here doesn't set the global pkgs, just where it'll be imported from (and where the global lib is
# derived from). We want home-manager to import pkgs itself so it'll apply config and overlays modularly. Any config
# and overlays previously applied will be passed on by `homeManagerConfiguration` though.
pkgs = pkgs'.${nixpkgs}.${system};
extraModules = modules ++ [
{
warnings = flatten [
(optional (nixpkgs != home-manager)
''
Using nixpkgs ${nixpkgs} with home-manager ${home-manager} may cause issues.
'')
];
_module.args = {
inherit inputs;
pkgs' = mapAttrs (_: p: p.${system}) pkgs';
};
}
(homeStateVersion home-manager)
];
});
in
mapAttrs mkHome {
"dev@castle" = {
system = "x86_64-linux";
nixpkgs = "unstable";
config = configs/castle.nix;
homeDirectory = "/home/dev";
username = "dev";
};
}

View File

@@ -0,0 +1,130 @@
{ lib, pkgs, pkgs', inputs, config, ... }@args:
let
inherit (lib) optionalAttrs versionAtLeast mkMerge mkIf mkDefault mkOption;
inherit (lib.my) mkOpt' dummyOption;
in
{
options = with lib.types; {
my = {
isStandalone = mkOption {
type = bool;
internal = true;
description = "Whether home-manager is running inside a NixOS system or not.";
};
};
# Only present in >=22.05, so forward declare
nix.registry = dummyOption;
};
config = mkMerge [
(mkIf (versionAtLeast config.home.stateVersion "22.05") {
nix.registry = {
pkgs = {
to = {
type = "path";
path = toString pkgs.path;
};
exact = true;
};
};
})
{
my.isStandalone = !(args ? osConfig);
programs = {
# Even when enabled this will only be actually installed in standalone mode
# Note: `home-manager.path` is for telling home-manager is installed and setting it in NIX_PATH, which we should
# never care about.
home-manager.enable = true;
lsd = {
enable = mkDefault true;
enableAliases = mkDefault true;
};
starship = {
enable = mkDefault true;
settings = {
aws.disabled = true;
};
};
bash = {
# This not only installs bash but has home-manager control .bashrc and friends
enable = mkDefault true;
initExtra =
''
flake-src() {
cd "$(nix eval "''${@:2}" --impure --raw --expr "builtins.getFlake \"$1\"")"
}
'';
};
direnv = {
enable = mkDefault true;
nix-direnv.enable = true;
stdlib =
''
# addition to nix-direnv's use_nix that registers outputs as gc roots (as well as the .drv)
use_nix_outputs() {
local layout_dir drv deps
layout_dir="$(direnv_layout_dir)"
drv="$layout_dir/drv"
deps="$layout_dir/deps"
if [ ! -e "$deps" ] || (( "$(stat --format=%Z "$drv")" > "$(stat --format=%Z "$deps")" )); then
rm -rf "$deps"
mkdir -p "$deps"
nix-store --indirect --add-root "$deps/out" --realise $(nix-store --query --references "$drv") > /dev/null
log_status renewed outputs gc roots
fi
}
'';
};
htop = {
enable = true;
settings = {};
};
};
home = {
packages = with pkgs; [
tree
iperf3
];
sessionVariables = {
EDITOR = "vim";
};
shellAliases = {
hm = "home-manager";
};
language.base = mkDefault "en_IE.UTF-8";
};
}
(mkIf (config.my.isStandalone || !args.osConfig.home-manager.useGlobalPkgs) {
# Note: If globalPkgs mode is on, then these will be overridden by the NixOS equivalents of these options
nixpkgs = {
overlays = [
(final: prev: { nix = inputs.nix.defaultPackage.${config.nixpkgs.system}; })
# TODO: Wait for https://github.com/NixOS/nixpkgs/pull/159074 to arrive to nixos-unstable
(final: prev: { remarshal = pkgs'.master.remarshal; })
];
config = {
allowUnfree = true;
};
};
})
(mkIf config.my.isStandalone {
fonts.fontconfig.enable = true;
home = {
packages = with pkgs; [
nix
];
};
})
];
}

View File

@@ -0,0 +1,24 @@
{ lib, pkgs, config, ... }:
let
inherit (lib) mkIf mkDefault mkMerge;
inherit (lib.my) mkBoolOpt';
cfg = config.my.gui;
in
{
options.my.gui = {
enable = mkBoolOpt' true "Enable settings and packages meant for graphical systems";
};
config = mkMerge [
(mkIf cfg.enable {
home = {
packages = with pkgs; [
(nerdfonts.override {
fonts = [ "DroidSansMono" "SourceCodePro" ];
})
];
};
})
];
}