diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e3c2943 --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +export DIRENV_WARN_TIMEOUT=20s + +eval "$(devenv direnvrc)" + +# The use_devenv function supports passing flags to the devenv command +# For example: use devenv --impure --option services.postgres.enable:bool true +use devenv diff --git a/.gitignore b/.gitignore index e2f5dd2..13888a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,12 @@ -result \ No newline at end of file +result +.stfolder +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..77574ee --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +stages: + - check + - eval + +variables: + NIX_CONFIG: "experimental-features = nix-command flakes" + +.default_nix: + image: nixos/nix + before_script: + - nix --version + - nix flake show + - echo "Using host: $(hostname)" + +flake-check: + stage: check + extends: .default_nix + script: + - nix flake check --all-systems + +flake-eval: + stage: eval + extends: .default_nix + script: + - nix flake show + - nix eval .#nixosConfigurations.tower.config.system.build.toplevel.outPath + - nix eval .#nixosConfigurations.electra.config.system.build.toplevel.outPath diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..685be6b --- /dev/null +++ b/devenv.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1753201456, + "owner": "cachix", + "repo": "devenv", + "rev": "39662b2c5b94ad06573c9aac4fe9f671260d1587", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1750779888, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1750441195, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "0ceffe312871b443929ff3006960d29b120dc627", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..75490cd --- /dev/null +++ b/devenv.nix @@ -0,0 +1,45 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + # https://devenv.sh/basics/ + env.GREET = "devenv"; + + # https://devenv.sh/packages/ + packages = [ pkgs.git ]; + + # https://devenv.sh/languages/ + # languages.rust.enable = true; + + # https://devenv.sh/processes/ + # processes.cargo-watch.exec = "cargo-watch"; + + # https://devenv.sh/services/ + # services.postgres.enable = true; + + # https://devenv.sh/scripts/ + scripts.hello.exec = '' + echo hello from $GREET + ''; + + enterShell = '' + hello + git --version + ''; + + # https://devenv.sh/tasks/ + # tasks = { + # "myproj:setup".exec = "mytool build"; + # "devenv:enterShell".after = [ "myproj:setup" ]; + # }; + + # https://devenv.sh/tests/ + enterTest = '' + echo "Running tests" + nix flake check --all-systems + ''; + + # https://devenv.sh/git-hooks/ + # git-hooks.hooks.shellcheck.enable = true; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..116a2ad --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/home/alisceon.nix b/home/alisceon.nix index c426374..c51faab 100644 --- a/home/alisceon.nix +++ b/home/alisceon.nix @@ -18,9 +18,22 @@ grep = "rg"; cat = "bat"; tsla-fan = "ipmitool -H 10.30.0.3 -U ADMIN -P ADMIN raw 0x30 0x70 0x66 0x01 0x0"; - nixos-switch = "sudo nixos-rebuild switch --flake .#${hostName}"; - nixos-test = "sudo nixos-rebuild build-vm --flake .#${hostName}"; + + # NixOS commands + nixoss = "sudo nixos-rebuild switch --flake .#${hostName}"; + nixos-main = "git checkout main && git pull && sudo nixos-rebuild switch --flake .#${hostName}"; + nixossr = "sudo nixos-rebuild switch --flake .#${hostName} && reboot"; + nixost = "sudo nixos-rebuild build-vm --flake .#${hostName}"; + + # Development commands + devt = "devenv test"; + devs = "devenv shell"; + devu = "devenv up"; + devi = "nix flake init -t path:/home/alisceon/Templates/devenv#python"; + pypod = "podman run --rm -it --network host -v '.:/run' -w '/run' python /run/"; + + # Tower commands weboot = "nix shell nixpkgs#efibootmgr -c sudo efibootmgr -n 0000 && reboot"; }; }; # end fish @@ -30,6 +43,7 @@ userEmail = "alisceon@protonmail.com"; extraConfig = { push = { autoSetupRemote = true; }; + init.defaultBranch = "main"; }; }; # end git vscode.enable = true; @@ -75,6 +89,10 @@ }; }; }; # end ssh + direnv = { + enable = true; + silent = true; + }; # end direnv }; # end programs # obsidian special case diff --git a/hosts/common.nix b/hosts/common.nix index 4ad7693..64ecfc9 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -2,13 +2,16 @@ { system.stateVersion = "24.05"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - nix.settings.auto-optimise-store = true; + nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; + auto-optimise-store = true; + trusted-users = [ "root" "alisceon" ]; + }; # end nix settings nix.gc = { automatic = true; dates = "weekly"; options = "--delete-older-than 7d"; - }; + }; # end nix gc console.keyMap = "sv-latin1"; networking.networkmanager.enable = true; @@ -91,9 +94,10 @@ # Browser firefox - # Editor + # Development vscode - obsidian + devenv + direnv # Virtualization podman @@ -108,6 +112,7 @@ steam krita edk2-uefi-shell + obsidian ]; environment.shells = with pkgs; [ fish ];