1
Fork 0

Add support for non-nixos systems

I run Debian on my Thinkpad and wanted to take advantage of nix on there
without also installing NixOS there, so here is added support for it.
This commit is contained in:
caem 2024-06-06 12:41:31 +02:00
parent c2ba41fd36
commit 62a2c850ae
Signed by: caem
GPG key ID: 69A830D03203405F
11 changed files with 103 additions and 21 deletions

View file

@ -47,6 +47,7 @@ modify and share this configuration to your heart's content, no attribution requ
``` ```
## Installing ## Installing
### NixOS
This configuration uses impermanence with btrfs snapshots so you'll have to partition This configuration uses impermanence with btrfs snapshots so you'll have to partition
your system in a certain way. your system in a certain way.
@ -75,3 +76,8 @@ in the `secrets/{user}` directory as `pass`.
Finally, in the config directory run `nixos-install --flake '.#'`, reboot and you're done. Finally, in the config directory run `nixos-install --flake '.#'`, reboot and you're done.
### Non-NixOS
Run the `non-nixos-install.sh` script. It will install both home-manager and nix.
Your user is assumed to be called "blank". You need to replace every instance of it
in case you want to use a different username.

22
non-nixos-install.sh Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env sh
# This script sets up nix and home-manager for distributions that are not NixOS.
set -e
BASE_PATH="$(dirname "$(realpath "$0")")"
if [ ! -d "/nix" ]; then
# Do multi-user installation
sh <(curl -L https://nixos.org/nix/install) --daemon
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
fi
if [ ! -x "$HOME/.nix-profile/bin/home-manager" ]; then
ln -svf "$BASE_PATH/users/blank/home-manager" "$HOME/.config/home-manager"
ln -svf "$BASE_PATH/users/blank/nixpkgs" "$HOME/.config/nixpkgs"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
fi

4
users/blank/README.md Normal file
View file

@ -0,0 +1,4 @@
This user is a standalone home-manager user which I use for
systems that are not NixOS but still make use of home-manager.
You should not import this user when running NixOS.

View file

@ -0,0 +1,30 @@
{ config, pkgs, ... }:
{
home.username = "blank";
home.homeDirectory = "/home/blank";
home.stateVersion = "24.05";
/*
home.packages = with pkgs; [
nvim
];
*/
home.file.".zshenv" = {
text = "source ~/.nix-profile/etc/profile.d/hm-session-vars.sh";
};
home.sessionVariables = {
EDITOR = "nvim";
ZDOTDIR = "${config.xdg.configHome}/zsh";
};
imports = [
./packages/nvim/neovim.nix
./packages/zsh/zsh-home.nix
];
programs.home-manager.enable = true;
}

View file

@ -0,0 +1 @@
../../../hu/packages/nvim

View file

@ -0,0 +1 @@
../../../hu/packages/zsh

View file

@ -0,0 +1,4 @@
{
allowUnfree = true;
}

View file

@ -1,9 +1,11 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
if [ -z "$FZF_TAB_FILE" ] && [ ! -d "$HOME/.cache/fzf-tab" ]; then if [ -z "$FZF_TAB_FILE" ]; then
echo "Installing fzf-tab" if [ ! -d "$HOME/.cache/fzf-tab" ]; then
git clone "https://github.com/Aloxaf/fzf-tab" "$HOME/.cache/fzf-tab" echo "Installing fzf-tab"
FZF_TAB_FILE="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh" git clone "https://github.com/Aloxaf/fzf-tab" "$HOME/.cache/fzf-tab"
fi
FZF_TAB_FILE="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh"
fi fi
autoload -Uz compinit autoload -Uz compinit

View file

@ -8,6 +8,10 @@ add_to_path() {
add_to_path "$HOME/.local/bin" add_to_path "$HOME/.local/bin"
if [ -f "/etc/profile.d/nix.sh" ]; then
source /etc/profile.d/nix.sh
fi
# Language package mangers # Language package mangers
if [ -n "$(command -v go)" ]; then if [ -n "$(command -v go)" ]; then
export GOPATH="$HOME/.local/share/go" export GOPATH="$HOME/.local/share/go"

View file

@ -1,15 +1,36 @@
{ pkgs, ... }: { config, pkgs, ... }:
{ {
home.file."/home/hu/.config/zsh/conf.d" = { home.packages = with pkgs; [
fzf
zsh-fzf-tab
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
nix-zsh-completions
thefuck
];
home.file."${config.xdg.configHome}/zsh/conf.d" = {
source = ./config/conf.d; source = ./config/conf.d;
recursive = true; recursive = true;
}; };
home.file."/home/hu/.config/zsh/.zshrc" = {
home.file."${config.xdg.configHome}/zsh/.zshrc" = {
text = '' text = ''
#!/usr/bin/env zsh #!/usr/bin/env zsh
SYNTAX_FILE="${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" SYNTAX_FILE="${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
FZF_TAB_FILE="${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh"
# On systems that are not on glibc 2.38, loading fzf-tab will fail. This prevents that.
if [ -f "/lib/x86_64-linux-gnu/libc.so.6" ]; then
GLIBC_VERSION="$(/lib/x86_64-linux-gnu/libc.so.6 | head -n1 | sed -e 's/.* //g' | rev | cut -c2- | rev)"
if [ "$GLIBC_VERSION" = "2.38" ]; then
FZF_TAB_FILE="${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh"
fi
else
FZF_TAB_FILE="${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh"
fi
AUTOSUGGEST_FILE="${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" AUTOSUGGEST_FILE="${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
'' + (builtins.readFile config/.zshrc); '' + (builtins.readFile config/.zshrc);
}; };

View file

@ -2,18 +2,5 @@
{ {
programs.zsh.enable = true; programs.zsh.enable = true;
environment.variables = {
ZDOTDIR = "${config.users.users.hu.home}/.config/zsh";
};
environment.systemPackages = with pkgs; [
fzf
zsh-fzf-tab
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
nix-zsh-completions
thefuck
];
} }