From 95c688766f7af1bd06e22ce150aa4628167455d8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 12 Apr 2024 10:01:17 +0000 Subject: [PATCH 1/7] home: vim: ftplugin: add bp --- modules/home/vim/after/ftplugin/bp.vim | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 modules/home/vim/after/ftplugin/bp.vim diff --git a/modules/home/vim/after/ftplugin/bp.vim b/modules/home/vim/after/ftplugin/bp.vim new file mode 100644 index 0000000..1224e7a --- /dev/null +++ b/modules/home/vim/after/ftplugin/bp.vim @@ -0,0 +1,7 @@ +" Create the `b:undo_ftplugin` variable if it doesn't exist +call ftplugined#check_undo_ft() + +" Add comment format +setlocal comments=b://,s1:/*,mb:*,ex:*/ +setlocal commentstring=//\ %s +let b:undo_ftplugin.='|setlocal comments< commentstring<' From a4ede5f6f403a6f73d8ac34ee56892be2e1a4f4f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 10 May 2023 13:04:06 +0000 Subject: [PATCH 2/7] templates: add rust-cargo --- templates/default.nix | 4 + templates/rust-cargo/.envrc | 5 + templates/rust-cargo/.gitignore | 6 ++ templates/rust-cargo/.woodpecker/check.yml | 31 ++++++ templates/rust-cargo/Cargo.lock | 7 ++ templates/rust-cargo/Cargo.toml | 8 ++ templates/rust-cargo/flake.nix | 112 +++++++++++++++++++++ templates/rust-cargo/rustfmt.toml | 0 templates/rust-cargo/src/main.rs | 3 + 9 files changed, 176 insertions(+) create mode 100644 templates/rust-cargo/.envrc create mode 100644 templates/rust-cargo/.gitignore create mode 100644 templates/rust-cargo/.woodpecker/check.yml create mode 100644 templates/rust-cargo/Cargo.lock create mode 100644 templates/rust-cargo/Cargo.toml create mode 100644 templates/rust-cargo/flake.nix create mode 100644 templates/rust-cargo/rustfmt.toml create mode 100644 templates/rust-cargo/src/main.rs diff --git a/templates/default.nix b/templates/default.nix index 31c3a81..44db753 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -7,4 +7,8 @@ path = ./c++-meson; description = "A C++ project using Meson"; }; + "rust-cargo" = { + path = ./rust-cargo; + description = "A Rust project using Cargo"; + }; } diff --git a/templates/rust-cargo/.envrc b/templates/rust-cargo/.envrc new file mode 100644 index 0000000..de77fcb --- /dev/null +++ b/templates/rust-cargo/.envrc @@ -0,0 +1,5 @@ +if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg=" +fi + +use flake diff --git a/templates/rust-cargo/.gitignore b/templates/rust-cargo/.gitignore new file mode 100644 index 0000000..5f360ff --- /dev/null +++ b/templates/rust-cargo/.gitignore @@ -0,0 +1,6 @@ +# Rust build directory +/target + +# Nix generated files +/.pre-commit-config.yaml +/result diff --git a/templates/rust-cargo/.woodpecker/check.yml b/templates/rust-cargo/.woodpecker/check.yml new file mode 100644 index 0000000..4ff7dba --- /dev/null +++ b/templates/rust-cargo/.woodpecker/check.yml @@ -0,0 +1,31 @@ +labels: + backend: local + +steps: +- name: pre-commit check + image: bash + commands: + - nix develop --command pre-commit run --all + +- name: nix flake check + image: bash + commands: + - nix flake check + +- name: notifiy + image: bash + environment: + ADDRESS: + from_secret: matrix_homeserver + ROOM: + from_secret: matrix_roomid + USER: + from_secret: matrix_username + PASS: + from_secret: matrix_password + commands: + - nix run github:ambroisie/matrix-notifier + when: + status: + - failure + - success diff --git a/templates/rust-cargo/Cargo.lock b/templates/rust-cargo/Cargo.lock new file mode 100644 index 0000000..4f9c86e --- /dev/null +++ b/templates/rust-cargo/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "project" +version = "0.0.0" diff --git a/templates/rust-cargo/Cargo.toml b/templates/rust-cargo/Cargo.toml new file mode 100644 index 0000000..4dfdc0b --- /dev/null +++ b/templates/rust-cargo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "project" +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/templates/rust-cargo/flake.nix b/templates/rust-cargo/flake.nix new file mode 100644 index 0000000..6d50369 --- /dev/null +++ b/templates/rust-cargo/flake.nix @@ -0,0 +1,112 @@ +{ + description = "A Rust project"; + + inputs = { + futils = { + type = "github"; + owner = "numtide"; + repo = "flake-utils"; + ref = "main"; + }; + + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; + }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + flake-utils.follows = "futils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = { self, futils, nixpkgs, pre-commit-hooks }: + { + overlays = { + default = final: _prev: { + project = with final; rustPlatform.buildRustPackage { + pname = "project"; + version = (final.lib.importTOML ./Cargo.toml).package.version; + + src = self; + + cargoLock = { + lockFile = "${self}/Cargo.lock"; + }; + + meta = with lib; { + description = "A Rust project"; + homepage = "https://git.belanyi.fr/ambroisie/project"; + license = licenses.mit; + maintainers = with maintainers; [ ambroisie ]; + }; + }; + }; + }; + } // futils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + self.overlays.default + ]; + }; + + pre-commit = pre-commit-hooks.lib.${system}.run { + src = self; + + hooks = { + clippy = { + enable = true; + settings = { + denyWarnings = true; + }; + }; + + nixpkgs-fmt = { + enable = true; + }; + + rustfmt = { + enable = true; + }; + }; + }; + in + { + checks = { + inherit (self.packages.${system}) project; + }; + + devShells = { + default = pkgs.mkShell { + inputsFrom = with self.packages.${system}; [ + project + ]; + + packages = with pkgs; [ + clippy + rust-analyzer + rustfmt + ]; + + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + + inherit (pre-commit) shellHook; + }; + }; + + packages = futils.lib.flattenTree { + default = pkgs.project; + inherit (pkgs) project; + }; + }); +} diff --git a/templates/rust-cargo/rustfmt.toml b/templates/rust-cargo/rustfmt.toml new file mode 100644 index 0000000..e69de29 diff --git a/templates/rust-cargo/src/main.rs b/templates/rust-cargo/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/templates/rust-cargo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 7e0cb867deb17d2f5b23670510147bb6dc59470f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 12 Apr 2024 15:19:29 +0000 Subject: [PATCH 3/7] pkgs: remove 'digestpp' I have packaged it upstream. --- pkgs/default.nix | 2 -- pkgs/digestpp/default.nix | 31 ------------------------------- 2 files changed, 33 deletions(-) delete mode 100644 pkgs/digestpp/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index e82a90c..a45bd7f 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -12,8 +12,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { diff-flake = pkgs.callPackage ./diff-flake { }; - digestpp = pkgs.callPackage ./digestpp { }; - dragger = pkgs.callPackage ./dragger { }; drone-rsync = pkgs.callPackage ./drone-rsync { }; diff --git a/pkgs/digestpp/default.nix b/pkgs/digestpp/default.nix deleted file mode 100644 index 2fd90db..0000000 --- a/pkgs/digestpp/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib -, fetchFromGitHub -, stdenv -}: -stdenv.mkDerivation { - pname = "digestpp"; - version = "0-unstable-2023-11-07"; - - src = fetchFromGitHub { - owner = "kerukuro"; - repo = "digestpp"; - rev = "ebb699402c244e22c3aff61d2239bcb2e87b8ef8"; - hash = "sha256-9X/P7DgZB6bSYjQWRli4iAXEFjhmACOVv3EYQrXuH5c="; - }; - - installPhase = '' - runHook preInstall - - mkdir -p $out/include/digestpp - cp -r *.hpp algorithm/ detail/ $out/include/digestpp - - runHook postInstall - ''; - - meta = with lib; { - description = "C++11 header-only message digest library"; - homepage = "https://github.com/kerukuro/digestpp"; - license = licenses.unlicense; - maintainers = with maintainers; [ ambroisie ]; - }; -} From e43cdbfa6519753cb5fb6d674d88eeecbd03e9ab Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 12 Apr 2024 15:19:56 +0000 Subject: [PATCH 4/7] pkgs: remove 'sqlite_orm' I have packaged it upstream. --- pkgs/default.nix | 2 -- pkgs/sqlite_orm/default.nix | 32 -------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 pkgs/sqlite_orm/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index a45bd7f..0212887 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -28,8 +28,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { rbw-pass = pkgs.callPackage ./rbw-pass { }; - sqlite_orm = pkgs.callPackage ./sqlite_orm { }; - unbound-zones-adblock = pkgs.callPackage ./unbound-zones-adblock { }; zsh-done = pkgs.callPackage ./zsh-done { }; diff --git a/pkgs/sqlite_orm/default.nix b/pkgs/sqlite_orm/default.nix deleted file mode 100644 index 3891eee..0000000 --- a/pkgs/sqlite_orm/default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ lib -, cmake -, fetchFromGitHub -, sqlite -, stdenv -}: -stdenv.mkDerivation (finalAttrs: { - pname = "sqlite_orm"; - version = "1.8.2"; - - src = fetchFromGitHub { - owner = "fnc12"; - repo = "sqlite_orm"; - rev = "v${finalAttrs.version}"; - hash = "sha256-KqphGFcnR1Y11KqL7sxODSv7lEvcURdF6kLd3cg84kc="; - }; - - nativeBuildInputs = [ - cmake - ]; - - propagatedBuildInputs = [ - sqlite - ]; - - meta = with lib; { - description = "Light header only SQLite ORM"; - homepage = "https://sqliteorm.com/"; - license = licenses.agpl3Only; # MIT license is commercial - maintainers = with maintainers; [ ambroisie ]; - }; -}) From 06b760e3ee7ffe73a78753295a6d4e10ef6fe98a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 12 Apr 2024 15:20:09 +0000 Subject: [PATCH 5/7] pkgs: remove 'bt-migrate' I have packaged it upstream. --- pkgs/bt-migrate/default.nix | 61 ------------------------------------- pkgs/default.nix | 2 -- 2 files changed, 63 deletions(-) delete mode 100644 pkgs/bt-migrate/default.nix diff --git a/pkgs/bt-migrate/default.nix b/pkgs/bt-migrate/default.nix deleted file mode 100644 index df99c55..0000000 --- a/pkgs/bt-migrate/default.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ lib -, boost -, cmake -, cxxopts -, digestpp -, fetchFromGitHub -, fmt -, jsoncons -, pugixml -, sqlite_orm -, stdenv -}: -stdenv.mkDerivation { - pname = "bt-migrate"; - version = "0-unstable-2023-08-17"; - - src = fetchFromGitHub { - owner = "mikedld"; - repo = "bt-migrate"; - rev = "e15a489c0c76f98355586ebbee08223af4e9bf50"; - hash = "sha256-kA6yxhbIh3ThmgF8Zyoe3I79giLVmdNr9IIrw5Xx4s0="; - }; - - nativeBuildInputs = [ - cmake - ]; - - buildInputs = [ - boost - cxxopts - fmt - jsoncons - pugixml - sqlite_orm - ]; - - cmakeFlags = [ - (lib.strings.cmakeBool "USE_VCPKG" false) - # NOTE: digestpp does not have proper CMake packaging (yet?) - (lib.strings.cmakeBool "USE_FETCHCONTENT" true) - (lib.strings.cmakeFeature "FETCHCONTENT_SOURCE_DIR_DIGESTPP" "${digestpp}/include/digestpp") - ]; - - # NOTE: no install target in CMake... - installPhase = '' - runHook preInstall - - mkdir -p $out/bin - cp BtMigrate $out/bin - - runHook postInstall - ''; - - meta = with lib; { - description = "Torrent state migration tool"; - homepage = "https://github.com/mikedld/bt-migrate"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ ambroisie ]; - mainProgram = "BtMigrate"; - }; -} diff --git a/pkgs/default.nix b/pkgs/default.nix index 0212887..6b7fce1 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,7 +1,5 @@ { pkgs }: pkgs.lib.makeScope pkgs.newScope (pkgs: { - bt-migrate = pkgs.callPackage ./bt-migrate { }; - bw-pass = pkgs.callPackage ./bw-pass { }; change-audio = pkgs.callPackage ./change-audio { }; From 6a22a80d4203111dd77bcd4ae7594f2ae194403b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 15 Apr 2024 14:06:21 +0000 Subject: [PATCH 6/7] home: direnv: update default flake Now that I (usually?) override `nixpkgs` in the registry, there's not much use in defaulting to `pkgs`. --- modules/home/direnv/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/home/direnv/default.nix b/modules/home/direnv/default.nix index 93a1f3b..4f1f4b6 100644 --- a/modules/home/direnv/default.nix +++ b/modules/home/direnv/default.nix @@ -8,8 +8,8 @@ in defaultFlake = mkOption { type = types.str; - default = "pkgs"; - example = "nixpkgs"; + default = "nixpkgs"; + example = "pkgs"; description = '' Which flake from the registry should be used for use pkgs by default. From b735eb4b98fd60f3e3f3bcdca33aec1eedc4719e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 15 Apr 2024 14:08:00 +0000 Subject: [PATCH 7/7] home: direnv: set 'DIRENV_DEFAULT_FLAKE' as needed --- modules/home/direnv/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/home/direnv/default.nix b/modules/home/direnv/default.nix index 4f1f4b6..67beb62 100644 --- a/modules/home/direnv/default.nix +++ b/modules/home/direnv/default.nix @@ -7,8 +7,8 @@ in enable = my.mkDisableOption "direnv configuration"; defaultFlake = mkOption { - type = types.str; - default = "nixpkgs"; + type = with types; nullOr str; + default = null; example = "pkgs"; description = '' Which flake from the registry should be used for @@ -39,7 +39,7 @@ in in lib.my.genAttrs' files linkLibFile; - home.sessionVariables = { + home.sessionVariables = lib.mkIf (cfg.defaultFlake != null) { DIRENV_DEFAULT_FLAKE = cfg.defaultFlake; }; };