From e9b3e28af64d13a4c31fd06279072506d9a990d2 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Sat, 11 Sep 2021 22:46:36 -0400 Subject: [PATCH] Use home-manager directly from flake.nix for non-NixOS (#10) * wip * put in same flake.nix * use home.nix directly * home2 * finalize --- Makefile | 10 ++++++- README.md | 11 ++++++++ flake.nix | 79 +++++++++++++++++++++++++++++++++++-------------------- home.nix | 44 ++++++++++++++++++++----------- 4 files changed, 98 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 2d69921..bdc52b3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,14 @@ all: sudo nixos-rebuild switch -j auto && systemctl restart --user emanote - + +# Not sure why this doesn't reliably work +homeBroken: + nix build --no-link ".#homeConfigurations."`whoami`@`hostname`".activationPackage" + ./result/activate + +# This requires the symlink to be setup; see README +home: + PATH="${HOME}/.nix-profile/bin/:${PATH}" home-manager switch freeupboot: # Delete all but the last few generations diff --git a/README.md b/README.md index 5282b09..e962dd3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,17 @@ This repository contains the Nix / NixOS configuration for all of my systems. St VSCode note: Ctrl+Shift+B will run `sudo nixos-rebuild switch`. +## Non-NixOS + +First time run, + +``` +ln -s /path/to/here ~/.config/nixpkgs # Why? See Makefile +make home +``` + +Afterwards, feel free to use `home-manager switch`. + ## Install notes - Hetzner dedicated from Linux Rescue system: https://github.com/serokell/nixos-install-scripts/pull/1#pullrequestreview-746593205 diff --git a/flake.nix b/flake.nix index 59090fe..079a1ca 100644 --- a/flake.nix +++ b/flake.nix @@ -57,35 +57,56 @@ { # The "name" in nixosConfigurations.${name} should match the `hostname` # - nixosConfigurations.p71 = mkHomeMachine - false - ./hosts/p71.nix - [ - inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p53 - ./features/desktopish - #./features/gnome.nix - ./features/desktopish/guiapps.nix - ./features/server/devserver.nix - ./features/ema/emanote.nix - #./features/virtualbox.nix - ./features/lxd.nix - #./features/server-mode.nix - # ./features/postgrest.nix - ./features/server/devserver.nix - ]; - nixosConfigurations.x1c7 = mkHomeMachine - ./hosts/x1c7.nix - [ - inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-7th-gen - ./features/distributed-build.nix - ./features/gnome.nix - ./features/desktopish/guiapps.nix - ]; - nixosConfigurations.facade = mkHomeMachine - true - ./hosts/facade.nix - [ - ]; + nixosConfigurations = { + p71 = mkHomeMachine + false + ./hosts/p71.nix + [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p53 + ./features/desktopish + #./features/gnome.nix + ./features/desktopish/guiapps.nix + ./features/server/devserver.nix + ./features/ema/emanote.nix + #./features/virtualbox.nix + ./features/lxd.nix + #./features/server-mode.nix + # ./features/postgrest.nix + ./features/server/devserver.nix + ]; + x1c7 = mkHomeMachine + ./hosts/x1c7.nix + [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-7th-gen + ./features/distributed-build.nix + ./features/gnome.nix + ./features/desktopish/guiapps.nix + ]; + facade = mkHomeMachine + true + ./hosts/facade.nix + [ + ]; + }; + + # non-NixOS systems + homeConfigurations = + let + username = "srid"; + hostname = "P71"; + in + { + # WSL ubuntu + "${username}@${hostname}" = home-manager.lib.homeManagerConfiguration { + inherit username system; + homeDirectory = "/home/${username}"; + configuration = import ./home.nix { + inherit inputs system; + bare = false; + pkgs = import nixpkgs { inherit system; }; + }; + }; + }; }; } diff --git a/home.nix b/home.nix index 3459972..5af76a4 100644 --- a/home.nix +++ b/home.nix @@ -1,7 +1,6 @@ +# HACK: bare { bare ? false, pkgs, inputs, system, ... }: let - nix-thunk = - (import (builtins.fetchTarball "https://github.com/obsidiansystems/nix-thunk/archive/master.tar.gz") { }).command; #himalayaSrc = inputs.himalaya; #himalaya = import ./features/email/himalaya.nix { inherit pkgs inputs system; }; neovim-nightly = inputs.neovim-nightly-overlay.packages.${system}.neovim; @@ -40,11 +39,6 @@ rec { # latex # texlive.combined.scheme-full - - git-remote-gcrypt - - nodePackages.mermaid-cli - asciidoctor ]; programs = { @@ -130,19 +124,37 @@ rec { bash = { enable = true; shellAliases = { - g = "git"; - t = "tig"; + g = "${pkgs.git}/bin/git"; + t = "${pkgs.tig}/bin/tig"; l = "${pkgs.exa}/bin/exa"; ll = "${pkgs.exa}/bin/exa -l"; ls = "l"; #h = "himalaya"; }; sessionVariables = { }; + bashrcExtra = '' + . ~/.nix-profile/etc/profile.d/nix.sh + export PATH=$HOME/.nix-profile/bin:$PATH + ''; }; - starship = { - enable = true; - }; + starship = + { + enable = true; + settings = { + username = { + format = "[$user](bold blue) "; + disabled = false; + show_always = true; + }; + hostname = { + ssh_only = false; + format = "on [$hostname](bold red) "; + trim_at = ".companyname.com"; + disabled = false; + }; + }; + }; bat.enable = true; autojump.enable = false; @@ -154,9 +166,9 @@ rec { programs.ssh = { enable = true; matchBlocks = { - "p71" = { - hostname = "192.168.2.76"; - }; + #"p71" = { + # hostname = "192.168.2.76"; + #}; }; }; @@ -168,5 +180,5 @@ rec { # You can update Home Manager without changing this value. See # the Home Manager release notes for a list of state version # changes in each release. - home.stateVersion = "21.03"; + # home.stateVersion = "21.03"; }