diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-08-09 18:06:06 +0800 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-08-09 18:06:06 +0800 |
commit | c811d1979c3c8042100792e9ded6a1d96c3747db (patch) | |
tree | 207ed083dc21a0eab2f99b1a6f10de4042c76fef | |
parent | 080241f63e15403b64e13ed647ca58faa52dbfde (diff) | |
download | nixos-configuration-c811d1979c3c8042100792e9ded6a1d96c3747db.tar.gz nixos-configuration-c811d1979c3c8042100792e9ded6a1d96c3747db.tar.bz2 nixos-configuration-c811d1979c3c8042100792e9ded6a1d96c3747db.zip |
feat(devenv): make new devenv config that integrates alejandra and commitizen
-rw-r--r-- | .envrc | 3 | ||||
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | devenv.lock | 122 | ||||
-rw-r--r-- | devenv.nix | 48 | ||||
-rw-r--r-- | devenv.yaml | 15 | ||||
-rw-r--r-- | home-manager/stvnliu/home.nix | 196 | ||||
-rw-r--r-- | home-manager/stvnliu/mako.nix | 12 | ||||
-rw-r--r-- | nixos/configuration.nix | 204 |
8 files changed, 413 insertions, 196 deletions
@@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=" + +use devenv
\ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d058db --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..c2f426c --- /dev/null +++ b/devenv.lock @@ -0,0 +1,122 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1723156315, + "owner": "cachix", + "repo": "devenv", + "rev": "ff5eb4f2accbcda963af67f1a1159e3f6c7f5f91", + "treeHash": "6624b16e4203ef3eae59ce8d5d19005e04741537", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1722869614, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "883180e6550c1723395a3a342f830bfc5c371f6b", + "treeHash": "e3ce01703c0d0324121e0d3ec6336275025b4ae6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1723056346, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3c977f1c9930f54066c085305b4b2291385e7a73", + "treeHash": "d6f89338ffb2ca32c20bc0f8d50009e1894ab804", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..90e4682 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,48 @@ +{ + pkgs, + lib, + config, + inputs, + ... +}: { + # https://devenv.sh/basics/ + env.GREET = "devenv"; + cachix.enable = false; + # https://devenv.sh/packages/ + packages = [pkgs.git]; + + # https://devenv.sh/languages/ + # languages.rust.enable = true; + languages.nix.enable = true; + pre-commit.hooks = { + alejandra.enable = true; + shellcheck.enable = true; + commitizen.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/tests/ + enterTest = '' + echo "Running tests" + git --version | grep --color=auto "${pkgs.git.version}" + ''; + + # https://devenv.sh/pre-commit-hooks/ + # pre-commit.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-manager/stvnliu/home.nix b/home-manager/stvnliu/home.nix index 9954cab..06eb48f 100644 --- a/home-manager/stvnliu/home.nix +++ b/home-manager/stvnliu/home.nix @@ -1,107 +1,107 @@ #his is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) { - inputs, - lib, - config, - pkgs, - ... -}: -{ -# You can import other home-manager modules here - imports = [ -# If you want to use home-manager modules from other flakes (such as nix-colors): -# inputs.nix-colors.homeManagerModule + inputs, + lib, + config, + pkgs, + ... +}: { + # You can import other home-manager modules here + imports = [ + # If you want to use home-manager modules from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModule -# You can also split up your configuration and import pieces of it here: -#./swaywm.nix - ./hypr - ./shells - ./variables.nix - ]; + # You can also split up your configuration and import pieces of it here: + #./swaywm.nix + ./hypr + ./shells + ./variables.nix + ./mako.nix + ]; - nixpkgs = { -# You can add overlays here - overlays = [ -# If you want to use overlays exported from other flakes: -# neovim-nightly-overlay.overlays.default + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default -# Or define it inline, for example: -# (final: prev: { -# hi = final.hello.overrideAttrs (oldAttrs: { -# patches = [ ./change-hello-to-hi.patch ]; -# }); -# }) - ]; -# Configure your nixpkgs instance - config = { -# Disable if you don't want unfree packages - allowUnfree = true; -# Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = _: true; - }; - }; + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = _: true; + }; + }; - home = { - username = "${config.myUserName}"; - homeDirectory = "/home/${config.myUserName}"; - file = { - "wallpaper.png".source = ./assets/gruvbox-wallpaper.png; - }; - }; - programs.neovim.enable = true; - home.packages = with pkgs; [ - protonvpn-gui - devenv - ]; - programs.git = { - enable = true; - package = pkgs.gitFull; - userName = config.myDisplayName; - userEmail = config.myEmail; - extraConfig = { - push.autoSetupRemote = true; - commit.gpgsign = true; - gpg.format = "ssh"; - gpg.ssh.allowedSignersFile = "/home/${config.myUserName}/.ssh/allowed_signers"; - user.signingkey = "/home/${config.myUserName}/.ssh/id_ed25519.pub"; - credential.helper = "libsecret"; - }; - }; + home = { + username = "${config.myUserName}"; + homeDirectory = "/home/${config.myUserName}"; + file = { + "wallpaper.png".source = ./assets/gruvbox-wallpaper.png; + }; + }; + programs.neovim.enable = true; + home.packages = with pkgs; [ + protonvpn-gui + devenv + ]; + programs.git = { + enable = true; + package = pkgs.gitFull; + userName = config.myDisplayName; + userEmail = config.myEmail; + extraConfig = { + push.autoSetupRemote = true; + commit.gpgsign = true; + gpg.format = "ssh"; + gpg.ssh.allowedSignersFile = "/home/${config.myUserName}/.ssh/allowed_signers"; + user.signingkey = "/home/${config.myUserName}/.ssh/id_ed25519.pub"; + credential.helper = "libsecret"; + }; + }; - programs.home-manager.enable = true; - programs.firefox.enable = true; -# Nicely reload system units when changing configs - systemd.user.startServices = "sd-switch"; - services.kanshi = { - enable = true; - profiles = { - undocked = { - outputs = [ - { - criteria = "eDP-1"; - scale = 1.0; - status = "enable"; - } - ]; - }; - docked = { - outputs = [ - { - criteria = "HDMI-A-1"; - position = "0,0"; - mode = "1920x1080@60Hz"; - } - { - criteria = "eDP-1"; - position = "0,0"; - status = "enable"; - } - ]; - }; - }; - systemdTarget = "hyprland-session.target"; - }; -# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "24.05"; + programs.home-manager.enable = true; + programs.firefox.enable = true; + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + services.kanshi = { + enable = true; + profiles = { + undocked = { + outputs = [ + { + criteria = "eDP-1"; + scale = 1.0; + status = "enable"; + } + ]; + }; + docked = { + outputs = [ + { + criteria = "HDMI-A-1"; + position = "0,0"; + mode = "1920x1080@60Hz"; + } + { + criteria = "eDP-1"; + position = "0,0"; + status = "enable"; + } + ]; + }; + }; + systemdTarget = "hyprland-session.target"; + }; + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "24.05"; } diff --git a/home-manager/stvnliu/mako.nix b/home-manager/stvnliu/mako.nix new file mode 100644 index 0000000..5b22460 --- /dev/null +++ b/home-manager/stvnliu/mako.nix @@ -0,0 +1,12 @@ +{ + pkgs, + lib, + ... +}: let + defaultTimeoutMillis = 5 * 1000; +in { + services.mako = { + enable = true; + defaultTimeout = defaultTimeoutMillis; + }; +} diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 1dc4bdf..9e89589 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -1,105 +1,113 @@ # This is your system's configuration file. # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) { - inputs, - lib, - config, - pkgs, - ... -}: -{ - imports = [ - ./variables.nix - #./greetd-sway.nix - ./nvidia.nix - ./fonts.nix - ./services/laptop.preset.nix - ./hardware-configuration.nix - ]; - - security.pam.services.hyprlock = {}; + inputs, + lib, + config, + pkgs, + ... +}: { + imports = [ + ./variables.nix + #./greetd-sway.nix + ./nvidia.nix + ./fonts.nix + ./services/laptop.preset.nix + ./hardware-configuration.nix + ]; - boot.loader = { - efi.canTouchEfiVariables = true; - grub = { - enable = true; - useOSProber = true; - efiSupport = true; - fsIdentifier = "label"; - devices = [ "nodev" ]; - extraEntries = '' - menuentry "Reboot" { - reboot - } - menuentry "Poweroff" { - halt - } - ''; - }; - }; - services.displayManager.sddm = { - enable = true; - wayland.enable = true; - }; - #systemd.user.services.kanshi = { - # description = "kanshi daemon"; - # serviceConfig = { - # Type = "simple"; - # ExecStart = ''${pkgs.kanshi}/bin/kanshi -c kanshi_config_file''; - # }; - #}; + security.pam.services.hyprlock = {}; + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; + systemd.user.services.mpris-proxy = { + description = "Mpris proxy"; + after = ["network.target" "sound.target"]; + wantedBy = ["default.target"]; + serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; + }; + boot.loader = { + efi.canTouchEfiVariables = true; + grub = { + enable = true; + useOSProber = true; + efiSupport = true; + fsIdentifier = "label"; + devices = ["nodev"]; + extraEntries = '' + menuentry "Reboot" { + reboot + } + menuentry "Poweroff" { + halt + } + ''; + }; + }; + services.displayManager.sddm = { + enable = true; + wayland.enable = true; + }; + #systemd.user.services.kanshi = { + # description = "kanshi daemon"; + # serviceConfig = { + # Type = "simple"; + # ExecStart = ''${pkgs.kanshi}/bin/kanshi -c kanshi_config_file''; + # }; + #}; - security.polkit.enable = true; - services.gnome.gnome-keyring.enable = true; - #programs.sway = { - # enable = true; - # wrapperFeatures.gtk = true; - #}; - programs.hyprland.enable = true; # enables Hyprland DM. - nixpkgs = { - overlays = [ - ]; - config = { - allowUnfree = true; - }; - }; + security.polkit.enable = true; + services.gnome.gnome-keyring.enable = true; + #programs.sway = { + # enable = true; + # wrapperFeatures.gtk = true; + #}; + programs.hyprland.enable = true; # enables Hyprland DM. + nixpkgs = { + overlays = [ + ]; + config = { + allowUnfree = true; + }; + }; - nix = let - flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs; - in { - settings = { - experimental-features = "nix-command flakes"; - flake-registry = ""; - nix-path = config.nix.nixPath; - }; - channel.enable = false; - registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs; - nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs; - }; - networking = { - hostName = "${config.myHostName}"; - networkmanager.enable = true; - }; - users.users = { - "${config.myUserName}" = { - initialPassword = "stevenpassword"; - isNormalUser = true; - openssh.authorizedKeys.keys = [ - ]; - packages = with pkgs; [ - nh - ]; - extraGroups = ["wheel"]; - }; - }; - services.openssh = { - enable = true; - settings = { - PermitRootLogin = "no"; - PasswordAuthentication = false; - }; - }; - services.automatic-timezoned.enable = true; -# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "24.05"; + nix = let + flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs; + in { + settings = { + experimental-features = "nix-command flakes"; + flake-registry = ""; + nix-path = config.nix.nixPath; + }; + channel.enable = false; + registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs; + nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs; + }; + networking = { + hostName = "${config.myHostName}"; + networkmanager.enable = true; + }; + users.users = { + "${config.myUserName}" = { + initialPassword = "stevenpassword"; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + ]; + packages = with pkgs; [ + nh + ]; + extraGroups = ["wheel"]; + }; + }; + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + }; + }; + services.automatic-timezoned.enable = true; + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "24.05"; } |