WIP
This commit is contained in:
parent
14cb73b526
commit
6fe4ca5f40
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
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
|
33
flake.nix
Normal file
33
flake.nix
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
description = "My Dotfiles Flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
|
||||
darwin = {
|
||||
url = "github:/lnl7/nix-darwin/master";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/master";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, ... }:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
pkgs = nixpacks.legacyPackages.${nixpkgs.system};
|
||||
in {
|
||||
homeConfigurations = {
|
||||
menno = gome-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
./home.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
75
home.nix
Normal file
75
home.nix
Normal file
@ -0,0 +1,75 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Home Manager needs a bit of information about you and the paths it should
|
||||
# manage.
|
||||
home.username = "menno";
|
||||
home.homeDirectory = "/home/menno";
|
||||
|
||||
# This value determines the Home Manager release that your configuration is
|
||||
# compatible with. This helps avoid breakage when a new Home Manager release
|
||||
# introduces backwards incompatible changes.
|
||||
#
|
||||
# You should not change this value, even if you update Home Manager. If you do
|
||||
# want to update the value, then make sure to first check the Home Manager
|
||||
# release notes.
|
||||
home.stateVersion = "23.11"; # Please read the comment before changing.
|
||||
|
||||
# The home.packages option allows you to install Nix packages into your
|
||||
# environment.
|
||||
home.packages = [
|
||||
# # Adds the 'hello' command to your environment. It prints a friendly
|
||||
# # "Hello, world!" when run.
|
||||
pkgs.hello
|
||||
|
||||
# # It is sometimes useful to fine-tune packages, for example, by applying
|
||||
# # overrides. You can do that directly here, just don't forget the
|
||||
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
|
||||
# # fonts?
|
||||
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
|
||||
|
||||
# # You can also create simple shell scripts directly inside your
|
||||
# # configuration. For example, this adds a command 'my-hello' to your
|
||||
# # environment:
|
||||
# (pkgs.writeShellScriptBin "my-hello" ''
|
||||
# echo "Hello, ${config.home.username}!"
|
||||
# '')
|
||||
];
|
||||
|
||||
# Home Manager is pretty good at managing dotfiles. The primary way to manage
|
||||
# plain files is through 'home.file'.
|
||||
home.file = {
|
||||
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
|
||||
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
|
||||
# # symlink to the Nix store copy.
|
||||
# ".screenrc".source = dotfiles/screenrc;
|
||||
|
||||
# # You can also set the file content immediately.
|
||||
# ".gradle/gradle.properties".text = ''
|
||||
# org.gradle.console=verbose
|
||||
# org.gradle.daemon.idletimeout=3600000
|
||||
# '';
|
||||
};
|
||||
|
||||
# Home Manager can also manage your environment variables through
|
||||
# 'home.sessionVariables'. If you don't want to manage your shell through Home
|
||||
# Manager then you have to manually source 'hm-session-vars.sh' located at
|
||||
# either
|
||||
#
|
||||
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
# or
|
||||
#
|
||||
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
# or
|
||||
#
|
||||
# /etc/profiles/per-user/menno/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
home.sessionVariables = {
|
||||
# EDITOR = "emacs";
|
||||
};
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
83
setup.sh
Normal file
83
setup.sh
Normal file
@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
NIX_CONFIG_URL="https://gist.githubusercontent.com/vleeuwenmenno/4671a99beca2e45dc4b0211de7865dfe/raw/8eb0656fe956db81b18d31caad54aaff66298e0a/nix.conf"
|
||||
|
||||
help() {
|
||||
echo "Usage: $0 [option...]" >&2
|
||||
echo
|
||||
echo " -i, --init Initial installation"
|
||||
echo " -c, --continue Continue installation"
|
||||
echo " -h, --help Display this help message"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
install_nix() {
|
||||
# Check if nix is installed (nix command is available)
|
||||
if command -v nix > /dev/null; then
|
||||
echo 'NIX is already installed.'
|
||||
else
|
||||
echo 'Installing NIX'
|
||||
sh <(curl -L https://nixos.org/nix/install) --daemon
|
||||
|
||||
echo 'Please restart your shell to continue...'
|
||||
touch ~/.setup-initial-done
|
||||
fi
|
||||
}
|
||||
|
||||
hush_login() {
|
||||
# If .hushlogin does not exist, create it
|
||||
if [ -f ~/.hushlogin ]; then
|
||||
echo 'Login message is already disabled.'
|
||||
else
|
||||
echo 'Disabling login message.'
|
||||
touch ~/.hushlogin
|
||||
fi
|
||||
}
|
||||
|
||||
nix_experimental() {
|
||||
if command -v nix > /dev/null; then
|
||||
echo 'NIX is already installed.'
|
||||
else
|
||||
install_nix
|
||||
fi
|
||||
|
||||
echo "Adding experimental-features to nix.conf..."
|
||||
grep -qxF 'experimental-features = nix-command flakes' /etc/nix/nix.conf || echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf
|
||||
}
|
||||
|
||||
nix_config_import() {
|
||||
# Check if nix configuration is already inserted
|
||||
if [ -f ~/.config/nix/nix.conf ]; then
|
||||
echo "Nix configuration is already inserted."
|
||||
exit 1
|
||||
else
|
||||
echo "Inserting nix configuration..."
|
||||
mkdir -p ~/.config/nix
|
||||
curl -s $NIX_CONFIG_URL -o ~/.config/nix/nix.conf
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if parameter is help, continue or initial
|
||||
if [ "$1" == "-c" ] || [ "$1" == "--continue" ]; then
|
||||
rm ~/.setup-initial-done
|
||||
|
||||
# Add experimental-features to nix.conf
|
||||
nix_experimental
|
||||
|
||||
# Insert nix configuration from github gist
|
||||
nix_config_import
|
||||
|
||||
|
||||
elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
||||
help
|
||||
elif [ "$1" == "-i" ] || [ "$1" == "--init" ]; then
|
||||
# Ubuntu specific, hide login message
|
||||
hush_login
|
||||
|
||||
# Install nix
|
||||
install_nix
|
||||
else
|
||||
help
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user