Skip to content

Commit ae3ee45

Browse files
committed
initial commit
0 parents  commit ae3ee45

File tree

6 files changed

+249
-0
lines changed

6 files changed

+249
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local_auto.nix

Readme.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# StratoKit dotfiles via home-manager
2+
3+
This manages our dotfiles and enables direnv
4+
5+
## Installation or upgrades
6+
7+
Run `./switch.sh`

flake.lock

+115
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
description = "A Home Manager flake";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
6+
home-manager.url = "github:nix-community/home-manager";
7+
home-manager.inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
10+
outputs = inputs:
11+
let
12+
inherit (builtins) stringLength substring;
13+
14+
local = import ./local_auto.nix;
15+
16+
hasSuffix =
17+
# Suffix to check for
18+
suffix:
19+
# Input string
20+
content:
21+
let
22+
lenContent = stringLength content;
23+
lenSuffix = stringLength suffix;
24+
in
25+
lenContent >= lenSuffix &&
26+
substring (lenContent - lenSuffix) lenContent content == suffix;
27+
28+
username = local.username;
29+
system = local.system;
30+
homeDirectory = if (hasSuffix "darwin" system) then "/Users/${username}" else "/home/${username}";
31+
extra = if (builtins.hasAttr "extra" local) then local.extra else null;
32+
in
33+
{
34+
defaultPackage = inputs.home-manager.defaultPackage;
35+
homeConfigurations = {
36+
${username} = inputs.home-manager.lib.homeManagerConfiguration rec {
37+
inherit username homeDirectory system;
38+
configuration.imports = [
39+
({ config, pkgs, lib, ... }: {
40+
nixpkgs.config = {
41+
allowUnfree = true;
42+
allowUnsupportedSystem = true;
43+
};
44+
})
45+
46+
./home.nix
47+
];
48+
};
49+
};
50+
};
51+
}

home.nix

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{ pkgs, lib, ... }:
2+
3+
let
4+
local = import ./local_auto.nix;
5+
username = local.username;
6+
in
7+
{
8+
programs.nix-index.enable = true;
9+
programs.command-not-found.enable = false;
10+
11+
programs.home-manager.enable = true;
12+
13+
programs.autojump.enable = true;
14+
15+
programs.direnv.enable = true;
16+
programs.direnv.nix-direnv.enable = true;
17+
18+
programs.zsh.enable = true;
19+
programs.bash.enable = true;
20+
21+
home.packages = with pkgs; [
22+
nixpkgs-fmt
23+
24+
nodejs
25+
26+
pstree
27+
rsync
28+
sqlite-interactive
29+
tree
30+
];
31+
}

switch.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
mydir=$(dirname "$0")
3+
case $mydir in /*) :;; *) mydir="$PWD/$mydir";; esac
4+
cd "$mydir"
5+
6+
function err() {
7+
echo "$*" >&2
8+
}
9+
10+
function die() {
11+
err "$1"
12+
exit 1
13+
}
14+
15+
function doSudo() {
16+
err "Executing as root: $*"
17+
sudo "$@"
18+
}
19+
20+
if ! type -p nix >/dev/null; then
21+
err "Nix is not installed, installing..."
22+
sh <(curl -L https://nixos.org/nix/install) --daemon
23+
source ~/.nix-profile/etc/profile.d/nix.sh
24+
if ! type -p nix >/dev/null; then
25+
die "couldn't find nix"
26+
fi
27+
fi
28+
29+
if ! grep -q flakes /etc/nix/nix.conf; then
30+
doSudo sh -c '(echo; echo "experimental-features = nix-command flakes") >> /etc/nix/nix.conf'
31+
fi
32+
33+
username=$USER
34+
hostname=$HOST
35+
system=$(nix-instantiate --eval --strict -E '(import <nixpkgs> {}).stdenv.hostPlatform.system')
36+
37+
if [ -z "$username" ] || [ -z "$hostname" ] || [ -z "$system" ]; then
38+
die "could not determine parameters"
39+
fi
40+
41+
echo "{ username = \"$username\"; hostname = \"$hostname\"; system = $system; }" > local_auto.nix
42+
43+
echo "Running home-manager switch"
44+
nix run . -- --flake . switch -b backup"$@"

0 commit comments

Comments
 (0)