From 7f158fa65e4b563a22ef9dbf67c7d3a9d34f7b11 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 21 Oct 2023 00:04:35 +0200 Subject: fix(hm/conf/taskwarrior/firefox): Generate the profile ids by counting Firefox expects the IDs to be consecutive, thus the previous hashing implementation didn't work. Additionally, these IDs are still all unique as we generate them by iteration over all possible projects --- hm/soispha/conf/firefox/default.nix | 29 +++++++++++++----------- hm/soispha/conf/taskwarrior/firefox/default.nix | 8 +++---- hm/soispha/conf/taskwarrior/firefox/lib.nix | 30 ------------------------- 3 files changed, 19 insertions(+), 48 deletions(-) delete mode 100644 hm/soispha/conf/taskwarrior/firefox/lib.nix (limited to 'hm') diff --git a/hm/soispha/conf/firefox/default.nix b/hm/soispha/conf/firefox/default.nix index 1f3b7062..d35b7256 100644 --- a/hm/soispha/conf/firefox/default.nix +++ b/hm/soispha/conf/firefox/default.nix @@ -22,6 +22,20 @@ video-pauser = (import ./functions/extensions/video-pauser.nix) {inherit pkgs video_pause;}; + profiles = { + "default" = { + inherit extensions search extraConfig bookmarks userChrome; + isDefault = true; + id = 0; + name = "default"; + }; + "clean" = { + isDefault = false; + id = 1; + name = "clean"; + }; + }; + taskwarriorProfiles = import ../taskwarrior/firefox { inherit extensions @@ -32,6 +46,7 @@ lib config ; + profile_size = builtins.length (builtins.attrNames profiles); }; search = { @@ -72,19 +87,7 @@ in { }; }; profiles = - { - "default" = { - inherit extensions search extraConfig bookmarks userChrome; - isDefault = true; - id = 0; - name = "default"; - }; - "clean" = { - isDefault = false; - id = 1; - name = "clean"; - }; - } + profiles // taskwarriorProfiles; }; } diff --git a/hm/soispha/conf/taskwarrior/firefox/default.nix b/hm/soispha/conf/taskwarrior/firefox/default.nix index 494d269a..f2379983 100644 --- a/hm/soispha/conf/taskwarrior/firefox/default.nix +++ b/hm/soispha/conf/taskwarrior/firefox/default.nix @@ -4,11 +4,11 @@ extraConfig, bookmarks, search, + profile_size, lib, config, ... }: let - hexLib = import ./lib.nix {inherit lib;}; inherit (config.soispha.taskwarrior.projects) projects; mkFirefoxProfile = { @@ -22,11 +22,9 @@ }; }; projects_id = - builtins.map (project: { + lib.imap1 (id: project: { name = project; - id = - hexLib.fromHexString - (builtins.hashString "sha256" project); + id = id + profile_size; }) projects; firefoxProfiles = builtins.listToAttrs (builtins.map mkFirefoxProfile projects_id); diff --git a/hm/soispha/conf/taskwarrior/firefox/lib.nix b/hm/soispha/conf/taskwarrior/firefox/lib.nix deleted file mode 100644 index 467b9a73..00000000 --- a/hm/soispha/conf/taskwarrior/firefox/lib.nix +++ /dev/null @@ -1,30 +0,0 @@ -{lib, ...}: { - fromHexString = hexString: let - fromHexChar = index: char: - { - "0" = 0; - "1" = 1; - "2" = 2; - "3" = 3; - "4" = 4; - "5" = 5; - "6" = 6; - "7" = 7; - "8" = 8; - "9" = 9; - "A" = 10; - "B" = 11; - "C" = 12; - "D" = 13; - "E" = 14; - "F" = 15; - } - .${lib.strings.toUpper char} - * ( - if index == 0 - then 1 - else index * 16 - ); - in - lib.lists.foldr (a: b: a + b) 0 (lib.lists.imap0 fromHexChar (lib.lists.reverseList (lib.strings.stringToCharacters hexString))); -} -- cgit 1.4.1