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:
parent
c2ba41fd36
commit
62a2c850ae
11 changed files with 103 additions and 21 deletions
|
@ -47,6 +47,7 @@ modify and share this configuration to your heart's content, no attribution requ
|
|||
```
|
||||
|
||||
## Installing
|
||||
### NixOS
|
||||
This configuration uses impermanence with btrfs snapshots so you'll have to partition
|
||||
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.
|
||||
|
||||
### 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
22
non-nixos-install.sh
Executable 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
4
users/blank/README.md
Normal 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.
|
||||
|
30
users/blank/home-manager/home.nix
Normal file
30
users/blank/home-manager/home.nix
Normal 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;
|
||||
}
|
||||
|
1
users/blank/home-manager/packages/nvim
Symbolic link
1
users/blank/home-manager/packages/nvim
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../hu/packages/nvim
|
1
users/blank/home-manager/packages/zsh
Symbolic link
1
users/blank/home-manager/packages/zsh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../hu/packages/zsh
|
4
users/blank/nixpkgs/config.nix
Normal file
4
users/blank/nixpkgs/config.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
allowUnfree = true;
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
if [ -z "$FZF_TAB_FILE" ] && [ ! -d "$HOME/.cache/fzf-tab" ]; then
|
||||
echo "Installing fzf-tab"
|
||||
git clone "https://github.com/Aloxaf/fzf-tab" "$HOME/.cache/fzf-tab"
|
||||
FZF_TAB_FILE="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh"
|
||||
if [ -z "$FZF_TAB_FILE" ]; then
|
||||
if [ ! -d "$HOME/.cache/fzf-tab" ]; then
|
||||
echo "Installing fzf-tab"
|
||||
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
|
||||
|
||||
autoload -Uz compinit
|
||||
|
|
|
@ -8,6 +8,10 @@ add_to_path() {
|
|||
|
||||
add_to_path "$HOME/.local/bin"
|
||||
|
||||
if [ -f "/etc/profile.d/nix.sh" ]; then
|
||||
source /etc/profile.d/nix.sh
|
||||
fi
|
||||
|
||||
# Language package mangers
|
||||
if [ -n "$(command -v go)" ]; then
|
||||
export GOPATH="$HOME/.local/share/go"
|
||||
|
|
|
@ -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;
|
||||
recursive = true;
|
||||
};
|
||||
home.file."/home/hu/.config/zsh/.zshrc" = {
|
||||
|
||||
home.file."${config.xdg.configHome}/zsh/.zshrc" = {
|
||||
text = ''
|
||||
#!/usr/bin/env 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"
|
||||
'' + (builtins.readFile config/.zshrc);
|
||||
};
|
||||
|
|
|
@ -2,18 +2,5 @@
|
|||
|
||||
{
|
||||
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
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue