Convert to flakes

Convert the install to flakes
Move home-manager into core repository
This commit is contained in:
Greg Hellings
2022-04-18 11:38:06 -05:00
parent 1326dc61a8
commit 13be0b0895
8 changed files with 356 additions and 8 deletions
Generated
+22
View File
@@ -18,6 +18,27 @@
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1649887911,
"narHash": "sha256-Af0Ppb1RZ7HWuxUvF0/O7h3cy8tqU2eKFyVwyA1ZD+w=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "7244c6715cb8f741f3b3e1220a9279e97b2ed8f5",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-21.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1638587357,
@@ -53,6 +74,7 @@
"root": {
"inputs": {
"agenix": "agenix",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_2"
}
}
+10
View File
@@ -7,6 +7,10 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
agenix.url = "github:ryantm/agenix";
home-manager = {
url = "github:nix-community/home-manager/release-21.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
@@ -15,7 +19,13 @@
inputs.agenix.nixosModule
./profiles/base.nix
./hosts/${hostname}
inputs.home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.users.greg = import ./home/home.nix "greg";
home-manager.users.root = import ./home/home.nix "root";
}
];
in {
nixosConfigurations = {
"2maccabees" = inputs.nixpkgs.lib.nixosSystem {
+95
View File
@@ -0,0 +1,95 @@
{ pkgs, ... }:
{
programs.bash = {
enable = true;
shellAliases = {
acp = "rsync --progress -ah";
agbuild = "ansible-galaxy collection build";
apub = "ansible-galaxy collection publish --api-key \${GALAXY_API_KEY}";
calc = "bc";
d = "deactivate";
devroles = "cd ~/src/ansible_collections/devroles";
gohome = "ssh greg@dns.greg-hellings.gmail.com.beta.tailscale.net -D localhost:10080";
ll = "ls -l";
molcol = "molecule -c ../../tests/molecule.yml";
packaging = "cd ~/src/packaging";
vdown = "vagrant destroy";
vhalt = "vagrant halt";
vos = "vagrant up --provision --provider openstack";
vprov = "vagrant provision";
vssh = "vagrant ssh";
vup = "vagrant up --provision --provider libvirt";
yaml2js = "python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)";
};
sessionVariables = {
ANSIBLE_COLLECTIONS_PATH="\${HOME}/src/";
CLICOLOR = "1";
EDITOR = "${pkgs.vim}/bin/vim";
GALAXY_API_KEY = "11498be21eb34b5776af72bcec59ddfdafcf27e5";
GIT_SSL_NO_VERIFY = "True";
LSCOLORS = "ExGxBxDxCxEgEdxbxgxcxd";
MAVEN_OPTS = " -Dmaven.wagon.http.ssl.insecure=true ";
OS_CLOUD = "default";
SWORD_PATH = "\${HOME}/.sword";
TIMEFORMAT = "%3Uu %3Ss %3lR %P%%";
VAGRANT_CLOUD_TOKEN = "zCQN8OBMy6Kl2g.atlasv1.JHsu0HsHMDdqCWqyUjJuCKDH0DyDzOHhbDBCrphUyjOP8OoM9i39SYmtk3Q4DKxfZXE";
};
profileExtra = ''
if [ -e /etc/profile ]; then
. /etc/profile
fi
'';
bashrcExtra = ''
function swordtag {
if [ x"$1" == "x" ]; then
echo "Please provide tag version"
return
fi
svn cp http://crosswire.org/svn/sword/branches/sword-1-8-x/ http://crosswire.org/svn/sword/tags/sword-$1/
}
function newdock {
if [ x"$1" == "x" -o x"$2" == "x" ]; then
echo "expected arguments [name] [source]"
return
fi
podman run -P --privileged=true -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v "$(pwd):/dmnt" -t -i --name="$1" "$2" /bin/bash
}
function rundock {
podman start -a -i "$1"
}
function ac {
source ~/venv/''${1}/bin/activate
}
function py2env {
/usr/bin/virtualenv -p /usr/bin/python2 "''${HOME}/venv/''${1}"
"''${HOME}/venv/''${1}/bin/pip" install -U pip
}
function py3env {
VENV_NAME="''${1}"
#PYVERSION="$(python3 -c "import sys;print(sys.version[:sys.version.find('.',2)])")"
#SITE_PACKAGES_PATH="/usr/lib64/python''${PYVERSION}/site-packages/"
#VENV_SITE_PACKAGES="''${HOME}/venv/''${VENV_NAME}/lib64/python''${PYVERSION}/site-packages/"
# Create the virtualenv and update pip to latest
/usr/bin/python3 -m venv --clear "''${HOME}/venv/''${VENV_NAME}" --system-site-packages
"''${HOME}/venv/''${1}/bin/python3" -m pip install -U pip
# Link SELinux into the environment if necessary
#if [ -d "''${SITE_PACKAGES_PATH}" ]; then
# ln -s "''${SITE_PACKAGES_PATH}/selinux" "''${VENV_SITE_PACKAGES}"
# ln -s ''${SITE_PACKAGES_PATH}/_selinux*.so "''${VENV_SITE_PACKAGES}"
#else
# echo "ERROR: LibSELinux not found for Python ''${PYVERSION}. Install system package to enable."
#fi
}
function unknown_host {
sed -i -e ''${1}d ~/.ssh/known_hosts
}
'';
};
}
+25
View File
@@ -0,0 +1,25 @@
{ ... }:
{
programs.git = {
enable = true;
userName = "Greg Hellings";
userEmail = "greg.hellings@gmail.com";
aliases = {
st = "status";
ci = "commit";
co = "checkout";
};
ignores = [
".*.swp" ".*.swo" ".*.swn" # vim
".idea" # IntelliJ
".DS_Store" # Macs
"Thumbs.db" # Windows
".tox" # Tox temp directory
];
extraConfig = {
push.default = "upstream";
pull.rebase = "false";
};
};
}
+12
View File
@@ -0,0 +1,12 @@
name: pkgs:
{
imports = [
./bash.nix
./git.nix
./vim.nix
];
home.username = name;
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
}
+164
View File
@@ -0,0 +1,164 @@
{ pkgs, ... }:
let
vim-stabs = pkgs.vimUtils.buildVimPlugin {
name = "vim-stabs";
src = pkgs.fetchFromGitHub {
owner = "Thyrum";
repo = "vim-stabs";
rev = "4654d4e000680e1f608b40f155af08873446ed63";
sha256 = "0hi1c5zv38hwxbyrf11fz97r728jgbppz4is7fwzwhfrzhwbw0ga";
};
};
in
{
programs.vim = {
enable = true;
plugins = with pkgs.vimPlugins; [
bufexplorer
ctrlp
nerdtree
vim-gitgutter
vim-flake8
vim-fugitive
vim-indent-guides
#vim-stabs
gruvbox
syntastic
];
settings = {
background = "dark";
copyindent = true;
expandtab = false;
hidden = true;
ignorecase = true;
mouse = "a";
number = true;
relativenumber = true;
shiftwidth = 4;
smartcase = true;
tabstop = 4;
};
extraConfig = ''
set nocompatible
syntax enable
set preserveindent
set softtabstop=0
set nowrap
set showcmd
set cursorline
set lazyredraw
set showmatch
set hlsearch
" Shows non-printing characters
set listchars=tab:\ ,extends:,precedes:,trail:·,eol:¬
set list
" Highlights bad whitespace
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Settings for CtrlP
set wildignore+=*.swp,*.pyc,*.class,.tox
" Base of search is ordered as
" r - searching up from here to the nearest marker (.git, .hg, .svn, etc)
" a - dir of current file, unless that's a subdirectory of CWD
" c - dir of current file
let g:ctrlp_working_path_mode = 'arc'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_user_command = {
\'types': {
\1: ['.git', 'git ls-files --cached --exclude-standard --others' ],
\},
\'fallback': 'find . -type f | grep -v -e "\.tox/" -e "\.git/"'
\}
" let g:ctrpl_match_func = { 'match': 'pymatcher#PyMatch' }
" Settings for NerdTree
let NERDTreeIgnore = ['\.pyc$', '\.o$', '\.class$']
" indent guides
let g:indent_guides_enable_on_vim_startup = 1
autocmd! BufWritePost .vimrc source $MYVIMRC
" Tell syntastic to use yamllint
let g:syntastic_yaml_checkers = ['yamllint']
let g:syntastic_yaml_yamllint_args = []
" Shortcuts for resolving git diff conflicts
let g:diffget_local_map = 'gl'
let g:diffget_upstream_map = 'gu'
" Key mappings
map <F2> <Esc>\be
map <F4> <Esc>:NERDTreeToggle<Cr>
map <F6> <Esc>:CtrlP<Cr>
" Allows navigating splits
map <C-j> <C-w>j<C-w><Cr>
map <C-k> <C-w>k<C-w><Cr>
map <C-h> <C-w>h<C-w><Cr>
map <C-l> <C-w>l<C-w><Cr>
colorscheme gruvbox
" ============================================================================
" User functions to just make life easier
" ============================================================================
" Toggle absolute line numbers when we don't have focus, and hybrid when
" we do have it
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" syntax highlighting for Vagrantfiles
augroup vagrant
au!
au BufRead,BufNewFile Vagrantfile set filetype=ruby
augroup END
" Creates the directory for a file if it doesn't already exist.
function! s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
" Return indent (all whitespace at start of a line), converted from
" tabs to spaces if what = 1, or from spaces to tabs otherwise.
" When converting to tabs, result has no redundant spaces.
function! Indenting(indent, what, cols)
let spccol = repeat(' ', a:cols)
let result = substitute(a:indent, spccol, '\t', 'g')
let result = substitute(result, ' \+\ze\t', ''', 'g')
if a:what == 1
let result = substitute(result, '\t', spccol, 'g')
endif
return result
endfunction
" Convert whitespace used for indenting (before first non-whitespace).
" what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces).
" cols = string with number of columns per tab, or empty to use 'tabstop'.
" The cursor position is restored, but the cursor will be in a different
" column when the number of characters in the indent of the line is changed.
function! IndentConvert(line1, line2, what, cols)
let savepos = getpos('.')
let cols = empty(a:cols) ? &tabstop : a:cols
execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e'
call histdel('search', -1)
call setpos('.', savepos)
endfunction
command! -nargs=? -range=% Space2Tab call IndentConvert(<line1>,<line2>,0,<q-args>)
command! -nargs=? -range=% Tab2Space call IndentConvert(<line1>,<line2>,1,<q-args>)
command! -nargs=? -range=% RetabIndent call IndentConvert(<line1>,<line2>,&et,<q-args>)
'';
};
}
+7
View File
@@ -0,0 +1,7 @@
{ ... }:
{
home.files.".xonshrc" = ''
'';
}
+21 -8
View File
@@ -8,6 +8,22 @@ let
];
in
{
# Enable flakes
nix = {
package = pkgs.nixFlakes;
# Keep freespace available, at a minimum, and enable Flakes
extraOptions = ''
experimental-features = nix-command flakes
min-free = ${toString (1024 * 1024 * 1024) }
max-free = ${toString (5 * 1024 * 1024 * 1024) }
'';
# Use hardlinking instead of copying when possible
autoOptimiseStore = true;
};
nixpkgs.config.allowUnfree = true;
# I am a fan of network manager, myself
networking.networkmanager.enable = true;
@@ -74,7 +90,10 @@ in
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix.defaultPackage."${system}"
diffutils
git
gnupatch
findutils
home-manager
htop
python3
@@ -82,6 +101,8 @@ in
tmux
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
xonsh
yamllint # Used in vim
];
i18n.defaultLocale = "en_US.UTF-8";
@@ -91,14 +112,6 @@ in
keyMap = "us";
};
# Keep freespace available, at a minimum
nix.extraOptions = ''
min-free = ${toString (1024 * 1024 * 1024) }
max-free = ${toString (5 * 1024 * 1024 * 1024) }
'';
# Use hardlinking instead of copying when possible
nix.autoOptimiseStore = true;
# The set of default values, which allow syou to keep system defaults set
# to a predictable value as you upgrade the system
system.stateVersion = "21.11";