From cef4aa7ae3a444b681dcc60fdf32b441cb4cb7e9 Mon Sep 17 00:00:00 2001 From: traxys Date: Thu, 5 Mar 2026 17:06:31 +0100 Subject: [PATCH] hostconfig/fabrial: Init from thinkpad-nixos --- hostconfig/default.nix | 1 + hostconfig/fabrial/default.nix | 42 +++ hostconfig/fabrial/extra_info.nix | 10 + hostconfig/fabrial/hm.nix | 510 ++++++++++++++++++++++++++ hostconfig/fabrial/roaming.toml | 7 + hostconfig/fabrial/telescope-team.lua | 43 +++ hostconfig/fabrial/work.nix | 120 ++++++ 7 files changed, 733 insertions(+) create mode 100644 hostconfig/fabrial/default.nix create mode 100644 hostconfig/fabrial/extra_info.nix create mode 100644 hostconfig/fabrial/hm.nix create mode 100644 hostconfig/fabrial/roaming.toml create mode 100644 hostconfig/fabrial/telescope-team.lua create mode 100644 hostconfig/fabrial/work.nix diff --git a/hostconfig/default.nix b/hostconfig/default.nix index fa2eda2..2fe4e7a 100644 --- a/hostconfig/default.nix +++ b/hostconfig/default.nix @@ -61,5 +61,6 @@ ./minus ./thinkpad-nixos ./gandalf + ./fabrial ]; } diff --git a/hostconfig/fabrial/default.nix b/hostconfig/fabrial/default.nix new file mode 100644 index 0000000..9d594e3 --- /dev/null +++ b/hostconfig/fabrial/default.nix @@ -0,0 +1,42 @@ +{ + self, + makeMachine, + flakeOverlays, + inputs, + lib, + ... +}: +{ + flake = { + homeConfigurations."boyerq@fabrial" = inputs.home-manager.lib.homeManagerConfiguration { + modules = + (with self.hmModules; [ + minimal + work + personal-cli + gui + wm + ]) + ++ [ + ./extra_info.nix + ./hm.nix + inputs.fioul.homeManagerModules.default + inputs.gsm.homeManagerModules.default + ]; + + pkgs = import inputs.nixpkgs rec { + system = "x86_64-linux"; + + overlays = flakeOverlays system; + + config.allowUnfreePredicate = + pkg: + builtins.elem (lib.getName pkg) [ + "slack" + "discord" + "spotify" + ]; + }; + }; + }; +} diff --git a/hostconfig/fabrial/extra_info.nix b/hostconfig/fabrial/extra_info.nix new file mode 100644 index 0000000..c94d723 --- /dev/null +++ b/hostconfig/fabrial/extra_info.nix @@ -0,0 +1,10 @@ +{lib, ...}: let + inherit (import ../../str-obf.nix lib) decode; + workDomain = "lenmlx.ziy"; +in { + extraInfo.email = "quentin.boyer@${decode workDomain}"; + + extraInfo.username = "traxys"; + + extraInfo.inputs.touchpad = "2:7:SynPS/2_Synaptics_TouchPad"; +} diff --git a/hostconfig/fabrial/hm.nix b/hostconfig/fabrial/hm.nix new file mode 100644 index 0000000..c57cb77 --- /dev/null +++ b/hostconfig/fabrial/hm.nix @@ -0,0 +1,510 @@ +{ + pkgs, + config, + lib, + ... +}: +let + projects = { + btf = [ + "bxi-test-frameworks" + "bxi-frameworks" + ]; + bxi3 = [ "bxi3" ]; + libs2 = [ "bxi-jenkins-libs2" ]; + hps = [ "bxi-hps" ]; + doc = [ "bxi-doc" ]; + qemu-bxi = [ "qemu" ]; + container = [ "bxi-containers" ]; + flash-tools = [ "bxi-flash-tools" ]; + gpumap = [ "gpumap" ]; + ofi = [ "libfabric-bxi-portals" ]; + lustre = [ "lustre-ptl4lnd" ]; + ptlnet = [ "ptlnet" ]; + openshmem = [ "sandia-openshmem" ]; + bxi-base = [ "bxi-base" ]; + bxi2-portals = [ "bxi-portals" ]; + bxi2-mod = [ "bxi-module" ]; + bxi2-ptltest = [ "bxi-portals-tests" ]; + bxicomm = [ "bxicomm" ]; + bxi3lnd = [ "lustre-release-bxi3" ]; + }; + + mailingLists = { + iommu = { + mail = "iommu@lists.linux.dev"; + tags = [ + "PATCH" + "RFC" + ]; + }; + kvm = { + mail = "kvm@vger.kernel.org"; + tags = [ + "PATCH" + "RFC" + ]; + }; + qemu = { + mail = "qemu-devel@nongnu.org"; + tags = [ + "PATCH" + "RFC" + "Stable" + ]; + }; + }; +in +{ + imports = [ ./work.nix ]; + + home.packages = with pkgs; [ + teams-for-linux + bear + clang-analyzer + clang-tools + cppcheck + jira-cli-go + libfabric + opensc + pcsclite + pcsc-tools + # Broken (27 feb 2024) + # python3Packages.clustershell + shellcheck + shfmt + slack + sshfs + nixgl.nixGLIntel + ]; + + programs.git = { + settings.user.name = "Quentin Boyer"; + settings.user.email = config.workAddr; + includes = [ + { + condition = "gitdir:~/Perso/"; + contents = { + user = { + email = "quentin@familleboyer.net"; + name = "traxys"; + }; + }; + } + ]; + }; + + home.sessionVariables = { + OPENSC_SO = "${pkgs.opensc}"; + EMAIL_CONN_TEST = "x"; + }; + + home.file = { + "libs/opensc-pkcs11.so".source = "${pkgs.opensc}/lib/opensc-pkcs11.so"; + "libs/libpcsclite.so.1".source = "${pkgs.pcsclite}/lib/libpcsclite.so.1"; + "bin/bxi-cn" = { + text = '' + #!/usr/bin/env bash + + exec podman run -e KERNEL_BULL_ENV=1 -it -v .:/src -w /src bril-docker-release/bxi-rhel:8.6 "$@" + ''; + executable = true; + }; + "bin/bxigpu-cn" = { + text = '' + #!/usr/bin/env bash + + exec podman run -e KERNEL_BULL_ENV=1 -it -v .:/src -w /src bril-docker-release/bxi-gpu:8.6 "$@" + ''; + executable = true; + }; + }; + + terminal.font.size = 10.5; + + programs.mbsync.enable = true; + programs.msmtp.enable = true; + programs.aerc = { + enable = true; + extraAccounts = { + work-t = + let + workCfg = config.accounts.email.accounts.work.aerc; + in + { + inherit (workCfg.extraAccounts) check-mail-cmd check-mail-timeout; + from = "Quentin Boyer <${config.workAddr}>"; + outgoing = "msmtpq --read-envelope-from --read-recipients"; + default = "_unread"; + postpone = "Drafts"; + source = "notmuch://~/Maildir"; + address-book-cmd = "${pkgs.notmuch-addrlookup}/bin/notmuch-addrlookup --format=aerc %s"; + query-map = + let + mkPatchDir = name: "projects/${name}=tag:${name}"; + patchDirs = builtins.concatStringsSep "\n" (builtins.map mkPatchDir (builtins.attrNames projects)); + + mkListDirs = name: '' + ext/${name}=tag:${name} + ext/${name}/non-patch=tag:${name} and tag:non-patch + ext/${name}/unread=tag:${name} and thread:{tag:unread} + ''; + listDirs = lib.pipe mailingLists [ + builtins.attrNames + (builtins.map mkListDirs) + (builtins.concatStringsSep "\n") + ]; + listIgnores = lib.pipe mailingLists [ + builtins.attrNames + (builtins.map (nm: "and not tag:${nm}")) + (builtins.concatStringsSep " ") + ]; + in + "${pkgs.writeText "querymap" '' + inbox=tag:inbox and not tag:spammy + _patches/inflight=thread:{tag:inflight} + _patches/review=thread:{tag:review} + _unread=thread:{tag:unread} ${listIgnores} + _todo=thread:{tag:todo} + + ${listDirs} + + ${patchDirs} + ''}"; + }; + }; + extraConfig = { + general.unsafe-accounts-conf = true; + + ui = { + mouse-enabled = true; + threading-enabled = true; + dirlist-tree = true; + }; + + filters = { + "text/plain" = "colorize"; + "text/calendar" = "calendar"; + "message/delivery-status" = "colorize"; + "message/rfc822" = "colorize"; + "text/html" = "html | colorize"; + "subject,~^\\[PATCH" = "delta"; + "subject,~^\\[RFC" = "delta"; + }; + + openers = { + "x-scheme-handler/http*" = "firefox"; + }; + }; + extraBinds = { + global = { + "" = ":prev-tab"; + "" = ":next-tab"; + "" = ":term"; + "?" = ":help keys"; + }; + + messages = { + "q" = ":quit"; + + "j" = ":next"; + "" = ":next"; + "" = ":next 100%"; + + "k" = ":prev"; + "" = ":prev"; + "" = ":prev 100%"; + + "g" = ":select 0"; + "G" = ":select -1"; + + "J" = ":next-folder"; + "K" = ":prev-folder"; + + "T" = ":toggle-threads"; + + "" = ":view"; + + "C" = ":compose"; + + "" = ":read"; + + "rr" = ":reply -a"; + "rq" = ":reply -aq"; + "Rr" = ":reply"; + "Rq" = ":reply -q"; + + "/" = ":search"; + "\\" = ":filter"; + "n" = ":next-result"; + "N" = ":prev-result"; + "" = ":clear"; + + "v" = ":mark -t"; + "V" = ":mark -v"; + + "tdi" = ":tag -inflight:select 0"; + "tdr" = ":tag -review:select 0"; + "tdt" = ":tag -todo:select 0"; + + "zI" = ":cf inbox"; + "zi" = ":cf _patches/inflight"; + "zr" = ":cf _patches/review"; + "zu" = ":cf _unread"; + "zt" = ":cf _todo"; + "zT" = ":cf tag:"; + }; + + view = { + "/" = ":toggle-key-passthrough/"; + + "q" = ":close"; + "O" = ":open"; + "S" = ":save"; + "D" = ":delete"; + "" = ":open-link "; + "f" = ":forward"; + + "rr" = ":reply -a"; + "rq" = ":reply -aq"; + "Rr" = ":reply"; + "Rq" = ":reply -q"; + + "H" = ":toggle-headers"; + "" = ":prev-part"; + "" = ":prev-part"; + "J" = ":next"; + "K" = ":prev"; + }; + + "view::passthrough" = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":toggle-key-passthrough"; + }; + + compose = { + "$noinherit" = true; + "$ex" = ""; + + "" = ":prev-field"; + "" = ":next-field"; + + "" = ":next-field"; + "" = ":prev-field"; + + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::editor" = { + "$noinherit" = true; + "$ex" = ""; + + "" = ":prev-field"; + "" = ":next-field"; + + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::review" = { + "y" = ":send"; + "n" = ":abort"; + "v" = ":preview"; + "p" = ":postpone"; + "q" = ":choose -o d discard abort -o p postpone postpone"; + "e" = ":edit"; + "a" = ":attach"; + "d" = ":detach"; + }; + }; + }; + + programs.notmuch = { + enable = true; + new.tags = [ "new" ]; + hooks = { + preNew = "${pkgs.isync}/bin/mbsync --all"; + postNew = + let + mkProjectMatch = project: "subject:'/PATCH\\s${project}\\s/'"; + mkProjectMatches = labels: lib.concatStringsSep " or " (builtins.map mkProjectMatch labels); + + mkProject = tag: labels: '' + notmuch tag +${tag} -unread -new -- tag:new and \( ${mkProjectMatches labels} \) and tag:me + notmuch tag +${tag} +unread -new -- tag:new and \( ${mkProjectMatches labels} \) and not tag:me + ''; + + projectFilters = builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList mkProject projects); + + spammyFilters = [ + "subject:'[confluence] Recommended in Confluence for Boyer, Quentin'" + "subject:'[PCI-SIG]'" + "from:enterprisedb.com" + ]; + + spammySearch = lib.concatStringsSep " or " spammyFilters; + + mkList = + tag: info: + let + subjects = lib.pipe info.tags [ + (builtins.map (tag: "subject:\"/\\[${tag}/\"")) + (builtins.concatStringsSep " OR ") + ]; + in + '' + notmuch tag +${tag} -new -- tag:new and to:${info.mail} and '(${subjects})' + notmuch tag +${tag} +non-patch -new -- tag:new and to:${info.mail} + ''; + tagLists = lib.pipe mailingLists [ + (lib.mapAttrsToList mkList) + (builtins.concatStringsSep "\n") + ]; + in + '' + notmuch tag +work -- tag:new and 'path:work/**' + ${tagLists} + notmuch tag +inflight -- tag:new and from:${config.workAddr} and subject:'/^\[PATCH/' + notmuch tag +review -- tag:new and not from:${config.workAddr} and subject:'/^\[PATCH/' + notmuch tag -unread +me -- tag:new and from:${config.workAddr} + notmuch tag -unread -new +spammy -- tag:new and \( ${spammySearch} \) + ${projectFilters} + notmuch tag +inbox +unread -new -- tag:new and not tag:me + notmuch tag +inbox -unread -new -- tag:new and tag:me + ''; + }; + }; + + programs.fish.shellAliases = { + "khal-today" = "khal list today today -f '{start-time}-{end-time}: {title}'"; + }; + + traxys.waybar.modules."custom/khal".enable = true; + traxys.waybar.modules."disk#root".enable = false; + traxys.waybar.modules."battery".enable = true; + traxys.waybar.modules."network#wifi" = { + enable = true; + interface = "wlp4s0"; + }; + + accounts = { + calendar = { + accounts.personal.primary = lib.mkForce false; + + accounts.work = { + primary = true; + remote = { + url = "http://localhost:1080/users/${config.workAddr}/calendar/"; + type = "caldav"; + userName = "${config.workAddr}"; + passwordCommand = [ + "echo" + "foobar" + ]; + }; + khal = { + enable = true; + color = "light green"; + }; + vdirsyncer.enable = true; + }; + }; + + email = { + accounts.work = rec { + address = config.workAddr; + imap = { + host = "localhost"; + port = 1143; + tls.enable = false; + }; + mbsync = { + enable = true; + create = "maildir"; + subFolders = "Verbatim"; + extraConfig = { + account = { + AuthMechs = "LOGIN"; + Timeout = 0; + }; + channel = { + Sync = [ + "Pull" + "New" + "Upgrade" + ]; + }; + }; + }; + passwordCommand = "echo foobar"; + notmuch.enable = true; + msmtp = { + enable = true; + extraConfig.auth = "plain"; + }; + primary = true; + realName = "Quentin Boyer"; + userName = address; + smtp = { + host = "localhost"; + port = 1025; + tls.enable = false; + }; + + aerc = { + enable = true; + extraAccounts = { + check-mail-cmd = "notmuch new"; + check-mail-timeout = "60s"; + }; + }; + }; + }; + }; + + systemd.user.services.notmuch-new = { + Unit = { + Description = "notmuch synchronization"; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.notmuch}/bin/notmuch new"; + }; + }; + + systemd.user.timers.notmuch = { + Unit = { + Description = "notmuch synchronization"; + }; + + Timer = { + OnCalendar = "*:0/5"; + Unit = "notmuch-new.service"; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + + home.homeDirectory = "/home/boyerq"; + home.username = "boyerq"; + home.stateVersion = "21.11"; + + traxys.wm = "niri"; + programs.niri.settings.binds."Mod+Shift+l".action = lib.mkForce ( + config.lib.niri.actions.spawn "/usr/bin/swaylock" + ); + + wayland.windowManager.sway.extraConfig = "exec /usr/libexec/polkit-gnome-authentication-agent-1"; + + programs.fish.functions = { + hwbmc = '' + echo "BMC for $argv[1] on https://localhost:9080" + ssh -N -L 9080:$argv[1]:443 bxib0 + ''; + }; +} diff --git a/hostconfig/fabrial/roaming.toml b/hostconfig/fabrial/roaming.toml new file mode 100644 index 0000000..e41afb3 --- /dev/null +++ b/hostconfig/fabrial/roaming.toml @@ -0,0 +1,7 @@ +[v4] +#"172.0.0.0/8" = "165.225.77.222:80" +#"172.0.0.0/8" = "127.0.0.1:8118" +"172.0.0.0/8" = "193.56.47.8:8080" +#"172.0.0.0/8" = "165.225.77.222:80" +"10.89.0.0/16" = "193.56.47.8:8080" +[v6] diff --git a/hostconfig/fabrial/telescope-team.lua b/hostconfig/fabrial/telescope-team.lua new file mode 100644 index 0000000..d24cdbd --- /dev/null +++ b/hostconfig/fabrial/telescope-team.lua @@ -0,0 +1,43 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +local work_domain = vim.env.WORK_DOMAIN + +local team_picker = function(opts) + opts = opts or {} + return pickers + .new(opts, { + prompt_title = "Team member", + finder = finders.new_table({ + results = vim.tbl_map(function(s) return string.format(s, work_domain) end, { + [[Quentin Boyer ""]], + [[Philippe Dutrueux ""]], + [[Sylvain Goudeau ""]], + [[Jonathan Espié--Caullet ""]], + [[Damien Bergamini ""]], + [[Clément Mathieu--Drif ""]], + [[Marie Badaroux ""]], + }), + }), + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + vim.api.nvim_put({ selection[1] }, "", false, true) + end) + return true + end, + }) + :find() +end + +return function() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local member = team_picker() + + vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { member }) +end diff --git a/hostconfig/fabrial/work.nix b/hostconfig/fabrial/work.nix new file mode 100644 index 0000000..cbf4ea6 --- /dev/null +++ b/hostconfig/fabrial/work.nix @@ -0,0 +1,120 @@ +{ + pkgs, + lib, + config, + ... +}: +let + rhelVersion = "9"; + bxiImageVersion = "0.7.2"; + inherit (import ../../str-obf.nix lib) decode; + workDomain = "lenmlx.ziy"; + oldWorkDomain = "hsid.xls"; + scmDomain = "gnsgrzwlsgmdjf.jdz.hsid-dlfenzld.xls"; +in +{ + options = { + workAddr = lib.mkOption { type = lib.types.str; }; + }; + + config = { + workAddr = "quentin.boyer@${decode workDomain}"; + + programs.nixvim = + { lib, ... }: + { + extraConfigLuaPre = '' + team_picker = dofile("${./telescope-team.lua}") + ''; + keymaps = [ + { + key = "R"; + mode = [ "n" ]; + action = lib.nixvim.mkRaw "team_picker"; + } + ]; + commands = { + Review = "lua team_picker()"; + }; + }; + + home.packages = [ + (pkgs.writeShellScriptBin "nwadminSendmail" '' + #!/usr/bin/env sh + # shellcheck disable=SC2029 + + ssh nwadmin "/usr/sbin/sendmail -r ${config.workAddr} $*" + exit $? + '') + (pkgs.writeShellScriptBin "mgit" '' + #!/usr/bin/env bash + + if [[ -z $BUILD_DIR ]]; then + BUILD_DIR=build + fi + + cd "$(git rev-parse --show-toplevel)" || { + echo "can't cd to toplevel" + exit 255 + } + + if [[ ! -d $BUILD_DIR ]]; then + echo "build directory '$BUILD_DIR' not found" + exit 1 + fi + + meson compile -C "$BUILD_DIR" "$@" + '') + (pkgs.writeShellScriptBin "podman-bxilint" '' + #!/usr/bin/env bash + + cd "$(git rev-parse --show-toplevel)" || { + echo "can't cd to toplevel" + exit 255 + } + + kernel_path=$(meson introspect build --buildoptions | jq -r '.[] | select(.name == "kernel_path") | .value') + + if [[ -z $kernel_path ]]; then + kernel_path=/usr/src/kernels/$(uname -r) + fi + + kernel_path=$(realpath "$kernel_path") + curdir=$(realpath .) + + podman run -it --rm -v "$curdir:$curdir:z" -v "$kernel_path:$kernel_path:z" -w "$curdir" \ + registry.sf.bds.${decode oldWorkDomain}/bril-docker-release/bxi-rhel${rhelVersion}:${bxiImageVersion} \ + bxilint "$@" + '') + pkgs.python3.pkgs.tappy + ]; + + home.sessionVariables = { + WORK_DOMAIN = decode workDomain; + }; + + programs.git-series-manager = { + enable = true; + settings = { + sendmail_args = [ + # Davmail + # "--from=${config.workAddr}" + # "--smtp-server=127.0.0.1" + # "--smtp-user=${config.workAddr}" + # "--smtp-pass=aaaa" + # "--smtp-encryption=plain" + # "--smtp-server-port=1025" + "--sendmail-cmd=nwadminSendmail" + "--to=dl-bxi-sw-ll-patches@${decode workDomain}" + ]; + repo_url_base = "https://${decode scmDomain}/scm/bril/"; + ci_url = "https://sf.bds.${decode oldWorkDomain}/jenkins/job/BRIL/job/\${component}/job/\${branch}/\${ci_job}"; + editor = "nvim"; + }; + }; + + programs.fish.shellAliases = { + gemail = ''git send-email --sendmail-cmd="nwadminSendmail" --to="dl-bxi-sw-ll-patches@${decode workDomain}"''; + }; + }; +}