update with hwtr-prince, everything looks fine

nix-components
pegasust 2022-12-08 02:04:20 -07:00
commit 42c2413ce0
51 changed files with 226 additions and 153 deletions

View File

@ -395,7 +395,7 @@ remap('n', '<leader>gs', function() require('neogit').open({}) end);
-- LSP settings -- LSP settings
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
require("inlay-hints").setup { require("inlay-hints").setup {
only_current_line = true, only_current_line = false,
eol = { eol = {
right_align = true, right_align = true,
} }
@ -440,9 +440,10 @@ local on_attach = function(client, bufnr)
nmap('<leader>wl', function() nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- enable inlay hints if available -- enable inlay hints if available
require('inlay-hints').on_attach(client, bufnr) require('inlay-hints').on_attach(client, bufnr)
end, '[W]orkspace [L]ist Folders')
end end
-- nvim-cmp -- nvim-cmp
@ -521,6 +522,7 @@ cmp.setup {
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'buffer' }, { name = 'buffer' },
{ name = 'path' }, { name = 'path' },
{ name = "conjure" },
-- { name = 'cmp_tabnine' }, -- { name = 'cmp_tabnine' },
}, },
} }
@ -540,6 +542,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
local servers = { local servers = {
'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals',
'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "pylsp", 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "pylsp",
"jsonls", "denols"
} }
require("mason").setup({ require("mason").setup({
ui = { ui = {
@ -549,12 +552,18 @@ require("mason").setup({
package_uninstalled = "" package_uninstalled = ""
}, },
check_outdated_packages_on_open = true, check_outdated_packages_on_open = true,
} },
-- The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration
-- Which means Mason's installed path is prioritized against our local install
-- see: https://git.pegasust.com/pegasust/aoc/commit/b45dc32c74d84c9f787ebce7a174c9aa1d411fc2
-- This introduces some pitfalls, so we'll take the approach of trusting user's local installation
PATH = "append";
}) })
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
ensure_installed = servers, ensure_installed = servers,
automatic_installation = true automatic_installation = true
}) })
local inlay_hint_tsjs = { local inlay_hint_tsjs = {
includeInlayEnumMemberValueHints = true, includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true,
@ -606,15 +615,25 @@ require('mason-lspconfig').setup_handlers({
require('lspconfig').tsserver.setup { require('lspconfig').tsserver.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
-- TODO: Have to figure out an alternative config for monorepo to prevent
-- Deno from injecting TS projects.
-- Monorepo support: spawn one instance of lsp within the git -- Monorepo support: spawn one instance of lsp within the git
-- repos. -- repos.
root_dir = require('lspconfig.util').root_pattern('.git'), -- root_dir = require('lspconfig.util').root_pattern('.git'),
root_dir = require('lspconfig.util').root_pattern('package.json'),
settings = { settings = {
javascript = inlay_hint_tsjs, javascript = inlay_hint_tsjs,
typescript = inlay_hint_tsjs, typescript = inlay_hint_tsjs,
} }
} }
end, end,
["denols"] = function()
require('lspconfig').denols.setup {
on_attach = on_attach,
capabilities = capabilities,
root_dir = require('lspconfig.util').root_pattern("deno.json", "deno.jsonc"),
}
end,
-- ["rust_analyzer"] = function() -- ["rust_analyzer"] = function()
-- require('lspconfig').rust_analyzer.setup { -- require('lspconfig').rust_analyzer.setup {
-- on_attach = on_attach, -- on_attach = on_attach,
@ -660,7 +679,7 @@ require("rust-tools").setup {
inlay_hints = { inlay_hints = {
-- automatically set inlay hints (type hints) -- automatically set inlay hints (type hints)
-- default: true -- default: true
auto = true, auto = false,
-- Only show inlay hints for the current line -- Only show inlay hints for the current line
only_current_line = false, only_current_line = false,
@ -853,6 +872,7 @@ require('zk.commands').add("ZkOrphans", function(options)
-- zk.edit opens notes picker -- zk.edit opens notes picker
require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" })
end) end)
--
-- ZkGrep: opens file picker -- ZkGrep: opens file picker
-- In the case where `match_ctor` is falsy, create a prompt. -- In the case where `match_ctor` is falsy, create a prompt.
-- This is so that we distinguish between ZkGrep and ZkNotes -- This is so that we distinguish between ZkGrep and ZkNotes
@ -920,6 +940,3 @@ require('lualine').setup {
require('nvim-surround').setup {} require('nvim-surround').setup {}
vim.cmd([[
let g:conjure#mapping#doc_word = v:false
]])

View File

@ -28,7 +28,10 @@
system = "x86_64-linux"; system = "x86_64-linux";
overlays = [ nixgl.overlay rust-overlay.overlays.default ]; overlays = [ nixgl.overlay rust-overlay.overlays.default ];
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs {
inherit system overlays;
config = { allowUnfree = true; };
};
lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; }); lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; });
in in
{ {
@ -74,22 +77,24 @@
}; };
}; };
}; };
# NOTE: This is never actually tested # NOTE: This is never actually tested. This is for Ubuntu@Felia
"ubuntu_admin" = home-manager.lib.homeManagerConfiguration { # "ubuntu_admin" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; # inherit pkgs;
modules = [ # modules = [
./home.nix # ./home.nix
]; # ];
extraSpecialArgs = { # extraSpecialArgs = {
myLib = lib; # myLib = lib;
myHome = { # myHome = {
username = "ubuntu_admin"; # username = "ubuntu_admin";
homeDirectory = "/home/ubuntu_admin"; # homeDirectory = "/home/ubuntu_admin";
shellInitExtra = '' # shellInitExtra = ''
'' + x11_wsl; # '' + x11_wsl;
}; # };
}; # };
}; # };
# Personal laptop
hwtr = home-manager.lib.homeManagerConfiguration { hwtr = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ modules = [
@ -102,7 +107,7 @@
homeDirectory = "/home/hwtr"; homeDirectory = "/home/hwtr";
packages = [ packages = [
pkgs.nixgl.nixGLIntel pkgs.nixgl.nixGLIntel
# pkgs.postman pkgs.postman
]; ];
shellAliases = { shellAliases = {
nixGL = "nixGLIntel"; nixGL = "nixGLIntel";

View File

@ -1,30 +1,48 @@
# myHome is injected from extraSpecialArgs in flake.nix # myHome is injected from extraSpecialArgs in flake.nix
{ config { config
, pkgs , pkgs # This is by default just ``= import <nixpkgs>{}`
, myHome , myHome
, ... , ...
}: }:
let nvim_pkgs = [ let
nvim_pkgs = [
# Yes, I desperately want neovim to work out-of-the-box without flake.nix for now # Yes, I desperately want neovim to work out-of-the-box without flake.nix for now
# I want at least python LSP to work everywhere because it's basically # I want at least python LSP to work everywhere because it's basically
# an alternative to bash script when I move to OpenColo # an alternative to bash script when I move to OpenColo
pkgs.neovim
pkgs.gccStdenv pkgs.gccStdenv
pkgs.gcc pkgs.gcc
pkgs.tree-sitter pkgs.tree-sitter
pkgs.ripgrep pkgs.ripgrep
pkgs.fzf pkgs.fzf
pkgs.sumneko-lua-language-server # pkgs.sumneko-lua-language-server
pkgs.ripgrep pkgs.ripgrep
pkgs.zk pkgs.zk
pkgs.fd pkgs.fd
pkgs.stdenv.cc.cc.lib
# Python3 as alternative to bash scripts :^) # Python3 as alternative to bash scripts :^)
(pkgs.python310Full.withPackages (pypkgs: [ # (pkgs.python310Full.withPackages (pypkgs: [
# pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this # # python-lsp-server's dependencies is absolutely astronomous
pypkgs.pynvim # nvim provider # # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this
pypkgs.ujson # pylsp seems to rely on this. satisfy it lol # pypkgs.pynvim # nvim provider
])) # pypkgs.ujson # pylsp seems to rely on this. satisfy it lol
]; in # ]))
];
proj_root = builtins.toString ./../..;
# TODO: put this in a seperate library
# callPackage supports both PATH and function as first param!
yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage
({ runCommand }:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution
''
echo "$yamlContent" | yq >$out
'')
{ };
# fromYamlPath = yamlPath: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlPath "any-output.json"));
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
in
{ {
home = { home = {
username = myHome.username; username = myHome.username;
@ -32,6 +50,7 @@ let nvim_pkgs = [
stateVersion = myHome.stateVersion or "22.05"; stateVersion = myHome.stateVersion or "22.05";
}; };
home.packages = pkgs.lib.unique ([ home.packages = pkgs.lib.unique ([
pkgs.ncdu
pkgs.htop pkgs.htop
pkgs.ripgrep pkgs.ripgrep
pkgs.unzip pkgs.unzip
@ -50,19 +69,16 @@ let nvim_pkgs = [
pkgs.lynx # Web browser at your local terminal pkgs.lynx # Web browser at your local terminal
# pkgs.tailscale # VPC;; This should be installed in system-nix # pkgs.tailscale # VPC;; This should be installed in system-nix
# pkgs.python310 # dev packages should be in jk pkgs.python310 # dev packages should be in jk
# pkgs.python310.numpy # pkgs.python310.numpy
# pkgs.python310Packages.tensorflow # pkgs.python310Packages.tensorflow
# pkgs.python310Packages.scikit-learn # pkgs.python310Packages.scikit-learn
] ++ (myHome.packages or [ ]) ++ nvim_pkgs); ] ++ (myHome.packages or [ ]) ++ nvim_pkgs);
## Configs ## ## Configs ##
# neovim xdg.configFile."nvim/init.lua".source = "${proj_root}//neovim/init.lua";
xdg.configFile."nvim/init.lua".text = builtins.readFile ../neovim/init.lua; xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
# starship sh xdg.configFile."zk/config.toml".source = "${proj_root}//zk/config.toml";
xdg.configFile."starship.toml".text = builtins.readFile ../starship/starship.toml;
# zk
xdg.configFile."config.toml".text = builtins.readFile ../zk/config.toml;
## Programs ## ## Programs ##
programs.jq = { programs.jq = {
@ -70,7 +86,8 @@ let nvim_pkgs = [
}; };
programs.alacritty = myHome.programs.alacritty or { programs.alacritty = myHome.programs.alacritty or {
enable = true; enable = true;
# settings = myLib.fromYaml (builtins.readFile ../alacritty/alacritty.yml); # settings = myLib.fromYaml (builtins.readFile "${proj_root}/alacritty/alacritty.yml");
settings = fromYaml (builtins.readFile "${proj_root}//alacritty/alacritty.yml");
}; };
# nix: Propagates the environment with packages and vars when enter (children of) # nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc # a directory with shell.nix-compatible and .envrc
@ -86,7 +103,7 @@ let nvim_pkgs = [
}; };
programs.tmux = { programs.tmux = {
enable = true; enable = true;
extraConfig = builtins.readFile ../tmux/tmux.conf; extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf";
}; };
programs.exa = { programs.exa = {
enable = true; enable = true;
@ -98,17 +115,22 @@ let nvim_pkgs = [
}; };
programs.home-manager.enable = true; programs.home-manager.enable = true;
programs.fzf.enable = true; programs.fzf.enable = true;
# programs.neovim = { programs.neovim = {
# enable = true; enable = true;
# viAlias = true; viAlias = true;
# vimAlias = true; vimAlias = true;
# withPython3 = true; withPython3 = true;
# withNodeJs = true; withNodeJs = true;
# # I use vim-plug, so I probably don't require packaging extraPackages = nvim_pkgs;
# # extraConfig actually writes to init-home-manager.vim (not lua) # extraPython3Packages = (pypkgs: [
# # https://github.com/nix-community/home-manager/pull/3287 # # pypkgs.python-lsp-server
# # extraConfig = builtins.readFile ../neovim/init.lua; # pypkgs.ujson
# }; # ]);
# I use vim-plug, so I probably don't require packaging
# extraConfig actually writes to init-home-manager.vim (not lua)
# https://github.com/nix-community/home-manager/pull/3287
# extraConfig = builtins.readFile "${proj_root}/neovim/init.lua";
};
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
@ -138,11 +160,13 @@ let nvim_pkgs = [
aliases = { aliases = {
a = "add"; a = "add";
c = "commit"; c = "commit";
ca = "commit --ammend"; ca = "commit --amend";
cm = "commit -m"; cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status"; sts = "status";
co = "checkout";
b = "branch";
}; };
# No idea why this is not appearing in home-manager search # No idea why this is not appearing in home-manager search
# It's in source code, though # It's in source code, though
@ -158,8 +182,8 @@ let nvim_pkgs = [
".direnv" ".direnv"
]; ];
extraConfig = { extraConfig = {
# cache credential for 10 minutes. # cache credential for 50 minutes (a pomodoro session)
credential.helper = "cache --timeout=600"; credential.helper = "cache --timeout=3000";
}; };
# why is this no longer valid? # why is this no longer valid?
# pull = { rebase=true; }; # pull = { rebase=true; };
@ -167,6 +191,6 @@ let nvim_pkgs = [
programs.ssh = { programs.ssh = {
enable = true; enable = true;
forwardAgent = true; forwardAgent = true;
extraConfig = builtins.readFile ../ssh/config; extraConfig = builtins.readFile "${proj_root}/ssh/config";
}; };
} }

View File

@ -0,0 +1,5 @@
# This module aims to be merge (not inject/override) with top-level pkgs to provide
# personalized/custom packages
{ pkgs, lib, ... }@pkgs_input: {
dot-hwtr = import "./dot-hwtr" pkgs_input;
}

View File

@ -0,0 +1,4 @@
{ pkgs, lib, ... }@pkgs_input: pkgs.stdenv.mkDerivation {
name = "dot-hwtr";
native
}

View File

@ -6,6 +6,7 @@ let
_boot = specialArgs._boot or { }; _boot = specialArgs._boot or { };
_services = specialArgs._services or { }; _services = specialArgs._services or { };
includeHardware = specialArgs.includeHardware or true; includeHardware = specialArgs.includeHardware or true;
proj_root = builtins.toString ./../..;
in in
with lib; with lib;
{ {
@ -16,6 +17,9 @@ with lib;
]; ];
boot = _boot; boot = _boot;
# prune old builds
nix.settings.auto-optimise-store = true;
system.stateVersion = "22.05"; system.stateVersion = "22.05";
# users.users.<defaultUser>.uid = 1000; # users.users.<defaultUser>.uid = 1000;
# networking.hostName = "nixos"; # networking.hostName = "nixos";
@ -33,7 +37,7 @@ with lib;
}; };
users.users.root = { users.users.root = {
# openssh runs in root, no? This is because port < 1024 requires root. # openssh runs in root, no? This is because port < 1024 requires root.
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile ../ssh/authorized_keys); openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/ssh/authorized_keys");
}; };
# Some basic programs # Some basic programs

View File

@ -1,8 +1,6 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { self, nixpkgs, ... }: outputs = { self, nixpkgs, ... }:
@ -36,10 +34,11 @@
prefixLength = 24; prefixLength = 24;
}]; }];
firewall = { firewall = {
enable = false; enable = true;
allowedTCPPorts = [ 80 443 22 ]; allowedTCPPorts = [ 80 443 22 ];
}; };
useDHCP = false; useDHCP = false;
# required so that we get IP address from linode
interfaces.eth0.useDHCP = true; interfaces.eth0.useDHCP = true;
}; };
_boot.loader.grub.enable = true; _boot.loader.grub.enable = true;
@ -59,6 +58,7 @@
}; };
}; };
}; };
# Highly suspect that thanks to nginx, ipv6 is disabled?
_services.nginx = { _services.nginx = {
enable = true; enable = true;
clientMaxBodySize = "100m"; # Allow big file transfers over git :^) clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
@ -94,76 +94,7 @@
allowedTCPPorts = [ 80 443 22 ]; allowedTCPPorts = [ 80 443 22 ];
}; };
useDHCP = false; useDHCP = false;
interfaces.eth0.useDHCP = true; # interfaces.eth0.useDHCP = true;
};
_boot.loader.grub.enable = true;
_boot.loader.grub.version = 2;
_services.openssh = {
permitRootLogin = "no";
enable = true;
};
_services.gitea = {
enable = true;
stateDir = "/gitea";
rootUrl = "https://git.pegasust.com";
settings = {
repository = {
"ENABLE_PUSH_CREATE_USER" = true;
"ENABLE_PUSH_CREATE_ORG" = true;
};
};
};
_services.nginx = {
enable = true;
clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.pegasust.com" = {
# Gitea hostname
sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem";
sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem";
forceSSL = true; # Runs on port 80 and 443
locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea
};
};
};
};
nixosConfigurations.lester = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
];
specialArgs = {
hostname = "lester";
_networking = {
firewall.enable = true;
useDHCP = false;
interfaces.eth0.useDHCP = true;
};
_boot.loader.grub.enable = true;
_boot.loader.grub.version = 2;
_services.openssh = {
permitRootLogin = "no";
enable = true;
};
};
};
nixosConfigurations.homeless = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
];
specialArgs = {
hostname = "homeless";
_networking = {
firewall = {
enable = false;
allowedTCPPorts = [ 80 443 ];
};
useDHCP = false;
interfaces.eth0.useDHCP = true;
}; };
_boot.loader.grub.enable = true; _boot.loader.grub.enable = true;
_boot.loader.grub.version = 2; _boot.loader.grub.version = 2;
@ -207,6 +138,7 @@
specialArgs = { specialArgs = {
hostname = "nyx"; hostname = "nyx";
_networking = { _networking = {
enableIPv6 = false;
interfaces.eth1.ipv4.addresses = [{ interfaces.eth1.ipv4.addresses = [{
address = "71.0.0.2"; address = "71.0.0.2";
prefixLength = 24; prefixLength = 24;

31
nixops/simple_hydra.nix Normal file
View File

@ -0,0 +1,31 @@
{
my-hydra = { config, pkgs, ... }: {
# send email
services.postfix = {
enable = true;
setSendmail = true;
};
# postgresql as a build queue (optimization possible?)
services.postgresql = {
enable = true;
package = pkgs.postgresql;
identMap = ''
hydra-users hydra hydra
hydra-users hydra-queue-runner hydra
hydra-users hydra-www hydra
hydra-users root postgres
hydra-users postgres postgres
'';
};
services.hydra = {
enable = true;
useSubstitutes = true;
# hydraURL =
};
networking = {
firewall = {
allowedTCPPorts = [ config.services.hydra.port ];
};
};
};
}

View File

@ -0,0 +1,25 @@
# guide: https://qfpl.io/posts/nix/starting-simple-hydra/
{
my-hydra = { config, pkgs, ... }: {
deployment = {
targetEnv = "virtualbox";
virtualbox.memorySize = 1024; # 1 GB``
virtualbox.vcpu = 2; # 2 vcpus :/ very limited on Linode, sorry
virtualbox.headless = true; # no gui pls
};
services = {
nixosManual.showManual = false; # save space, just no manual on our nix installation
ntp.enable = true; # time daemon
openssh = {
allowSFTP = false; # Prefer using SCP because connection is less verbose (?)
# we are going to generate rsa public key pair to machine
passwordAuthentication = false; # client-pubkey/server-prikey or dig yourself
};
};
users = {
mutableUsers = false; # Remember Trien's Windows freeze function? this is it.
# Yo, allow trusted users through ok?
users.root.openssh.authorizedKeys.keyFiles = [ "ssh/authorizedKeys" ];
};
};
}

View File

@ -1,23 +1,30 @@
#!/usr/bin/env sh #!/usr/bin/env sh
## Configures a new nixos system to this repository
## Blame: Hung Tran (Pegasust) <pegasucksgg@gmail.com>
set -xv set -xv
HOSTNAME=${1} HOSTNAME=${1}
if [ -z $HOSTNAME ]; then if [ -z $HOSTNAME ]; then
echo "Missing hostname as first param" 1>&2 current_hostname=$(hostname)
exit 1 echo "Missing hostname as first param."
echo "Type the hostname you want to be here"
read -p "[${current_hostname}] > " HOSTNAME
HOSTNAME=${HOSTNAME:-${current_hostname}}
read -p "Using hostname: ${HOSTNAME}. Press ENTER to continue." _WHATEVER_
fi fi
# Where is this script located # Where is this script located
SCRIPT_DIR=$(realpath $(dirname $0)) SCRIPT_DIR=$(realpath $(dirname $0))
echo "SCRIPT_DIR: ${SCRIPT_DIR}" echo "SCRIPT_DIR: ${SCRIPT_DIR}"
SYSNIX_DIR="${SCRIPT_DIR}/../system-nix" SYSNIX_DIR="${SCRIPT_DIR}/../nix-conf/system"
# Copy hardware-configuration of existing machine onto our version control # Copy hardware-configuration of existing machine onto our version control
SYSNIX_PROF="${SYSNIX_DIR}/profiles/${HOSTNAME}" SYSNIX_PROF="${SYSNIX_DIR}/profiles/${HOSTNAME}"
HARDWARE_CONF="${SYSNIX_PROF}/hardware-configuration.nix" HARDWARE_CONF="${SYSNIX_PROF}/hardware-configuration.nix"
if [ ! -f "${HARDWARE_CONF}" ]; then; if [ ! -f "${HARDWARE_CONF}" ]; then
mkdir "$SYSNIX_PROF" mkdir "$SYSNIX_PROF"
sudo cp /etc/nixos/hardware-configuration.nix ${HARDWARE_CONF} sudo cp /etc/nixos/hardware-configuration.nix ${HARDWARE_CONF}
fi fi

19
scripts/hm-switch.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env sh
# NOTE: Untested on case of no home-manager
set -xv
# Where this script located
SCRIPT_DIR=$(realpath $(dirname $0))
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
HOME_MANAGER_DIR="${SCRIPT_DIR}/../nix-conf/home-manager"
# test if we have home-manager, if not, attempt to use nix to put home-manager to
# our environment
if [ $(home-manager &>/dev/null) ]; then
nix-shell -p home-manager --run "home-manager switch --flake $HOME_MANAGER_DIR"
else
home-manager switch --flake "$HOME_MANAGER_DIR"
fi

0
scripts/sys-switch.sh Executable file
View File