Skip to content

Commit

Permalink
spotify-player: add module
Browse files Browse the repository at this point in the history
spotify-player: tests

chore: format

fix: declare in modules.nix

spotify-player: add news entry

spotify-player: implement review suggestions

spotify-player: fix maintainers

Squashed commit of the following:

commit 1c43dcf
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 15 09:42:51 2024 +0200

    ci: bump peaceiris/actions-gh-pages from 3 to 4

    Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
    - [Release notes](https://github.com/peaceiris/actions-gh-pages/releases)
    - [Changelog](https://github.com/peaceiris/actions-gh-pages/blob/main/CHANGELOG.md)
    - [Commits](peaceiris/actions-gh-pages@v3...v4)

    ---
    updated-dependencies:
    - dependency-name: peaceiris/actions-gh-pages
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 59d50bc
Author: Nathan Henrie <[email protected]>
Date:   Mon Apr 15 01:40:27 2024 -0600

    espanso: enable module on darwin

commit 9f32c66
Author: Jose Plana <[email protected]>
Date:   Wed Apr 10 13:34:46 2024 +0200

    k9s: configuration files in Darwin without XDG

    Support alternate configuration files for k9s in darwin where XDG is
    not mandated and k9s expects configuration files in
    `~/Library/Application Support/k9s/`.

commit 76a1650
Author: Jose Plana <[email protected]>
Date:   Wed Apr 10 10:24:46 2024 +0200

    k9s: fix typos in configuration file names

commit 630a099
Author: Philipp Mildenberger <[email protected]>
Date:   Sun Apr 14 08:58:16 2024 +0200

    nushell: fix nushell config path on darwin

commit 4cc3c91
Author: home-manager-bot <[email protected]>
Date:   Sun Apr 14 08:56:05 2024 +0200

    flake.lock: Update

    Flake lock file updates:

    • Updated input 'nixpkgs':
        'github:NixOS/nixpkgs/fd281bd6b7d3e32ddfa399853946f782553163b5' (2024-04-03)
      → 'github:NixOS/nixpkgs/1042fd8b148a9105f3c0aca3a6177fd1d9360ba5' (2024-04-10)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit f33d508
Author: Mitchell Skaggs <[email protected]>
Date:   Sat Apr 13 12:59:33 2024 -0500

    rio: remove redundant `lib.mdDoc` call

    This is an error as of NixOS/nixpkgs#303841

    It seems to have been missed in nix-community#4215

commit 8fdf329
Author: MiSumiSumi <[email protected]>
Date:   Sat Apr 13 23:50:15 2024 +0900

    neovim: enable use of external package manager (nix-community#5225)

    * neovim: add extraWrapperArgs option

    pass external arguments to neovim-unwrapper
    this gives users more flexibility in managing neovim configuration

    * neovim: add test for `extraWrapperArgs`

commit 40ab43a
Author: Bryn Edwards <[email protected]>
Date:   Sat Apr 13 07:27:43 2024 +0100

    foot: set PATH in server's systemd unit file

    If not set, foot's terminal spawning shortcut will not work as the
    `footclient` binary is not on the server's PATH.

commit 3135748
Author: Ramses <[email protected]>
Date:   Wed Apr 10 16:39:52 2024 +0200

    fish: use the subcommand style for the status command (nix-community#4584)

    The flag style has been deprecated and will eventually be removed.

commit 18f89ef
Author: Tony Zorman <[email protected]>
Date:   Wed Apr 10 08:29:32 2024 +0200

    firefox: add containersForce flag

    Firefox, upon exit, creates the default containers.json file in place of
    the one that home-manager created. This leads to errors when switching
    to a new profile, as home-manager is careful with overwriting existing
    files. The added option toggles that behaviour.

    Closes: nix-community#4989

commit b00d0e4
Author: Jack W <[email protected]>
Date:   Tue Apr 9 14:48:15 2024 -0400

    bun: add module

commit 40a9961
Author: Mario Rodas <[email protected]>
Date:   Tue Apr 9 01:57:29 2024 -0500

    fzf: add compatibility with fzf≥0.48.0

    fzf 0.48.0 [1] changed the way it integrates with shells.

    [1] https://github.com/junegunn/fzf/releases/tag/0.48.0

commit a561ad6
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Apr 7 03:59:32 2024 +0000

    flake.lock: Update

    Flake lock file updates:

    • Updated input 'nixpkgs':
        'github:NixOS/nixpkgs/d8fe5e6c92d0d190646fb9f1056741a229980089' (2024-03-29)
      → 'github:NixOS/nixpkgs/fd281bd6b7d3e32ddfa399853946f782553163b5' (2024-04-03)

commit b787726
Author: Smaug123 <[email protected]>
Date:   Fri Apr 5 14:05:00 2024 +0100

    home-manager: extract inline shell script to file
  • Loading branch information
diniamo committed Apr 16, 2024
1 parent 782eed8 commit f072b47
Show file tree
Hide file tree
Showing 36 changed files with 789 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
nix-build -A docs.html
cp -r result/share/doc/home-manager public
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 6 additions & 51 deletions modules/files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,59 +79,14 @@ in
(mapAttrsToList (n: v: v.target)
(filterAttrs (n: v: v.force) cfg));

check = pkgs.writeText "check" ''
${config.lib.bash.initHomeManagerLib}
# A symbolic link whose target path matches this pattern will be
# considered part of a Home Manager generation.
homeFilePattern="$(readlink -e ${escapeShellArg builtins.storeDir})/*-home-manager-files/*"
forcedPaths=(${forcedPaths})
newGenFiles="$1"
shift
for sourcePath in "$@" ; do
relativePath="''${sourcePath#$newGenFiles/}"
targetPath="$HOME/$relativePath"
storeDir = escapeShellArg builtins.storeDir;

forced=""
for forcedPath in "''${forcedPaths[@]}"; do
if [[ $targetPath == $forcedPath* ]]; then
forced="yeah"
break
fi
done
if [[ -n $forced ]]; then
verboseEcho "Skipping collision check for $targetPath"
elif [[ -e "$targetPath" \
&& ! "$(readlink "$targetPath")" == $homeFilePattern ]] ; then
# The target file already exists and it isn't a symlink owned by Home Manager.
if cmp -s "$sourcePath" "$targetPath"; then
# First compare the files' content. If they're equal, we're fine.
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be skipped since they are the same"
elif [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
# Next, try to move the file to a backup location if configured and possible
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT"
if [[ -e "$backup" ]]; then
errorEcho "Existing file '$backup' would be clobbered by backing up '$targetPath'"
collision=1
else
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be moved to '$backup'"
fi
else
# Fail if nothing else works
errorEcho "Existing file '$targetPath' is in the way of '$sourcePath'"
collision=1
fi
fi
done
check = pkgs.substituteAll {
src = ./files/check-link-targets.sh;

if [[ -v collision ]] ; then
errorEcho "Please move the above files and try again or use 'home-manager switch -b backup' to back up existing files automatically."
exit 1
fi
'';
inherit (config.lib.bash) initHomeManagerLib;
inherit forcedPaths storeDir;
};
in
''
function checkNewGenCollision() {
Expand Down
53 changes: 53 additions & 0 deletions modules/files/check-link-targets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- mode: sh; sh-shell: bash -*-

@initHomeManagerLib@

# A symbolic link whose target path matches this pattern will be
# considered part of a Home Manager generation.
homeFilePattern="$(readlink -e @storeDir@)/*-home-manager-files/*"

forcedPaths=(@forcedPaths@)

newGenFiles="$1"
shift
for sourcePath in "$@" ; do
relativePath="${sourcePath#$newGenFiles/}"
targetPath="$HOME/$relativePath"

forced=""
for forcedPath in "${forcedPaths[@]}"; do
if [[ $targetPath == $forcedPath* ]]; then
forced="yeah"
break
fi
done

if [[ -n $forced ]]; then
verboseEcho "Skipping collision check for $targetPath"
elif [[ -e "$targetPath" \
&& ! "$(readlink "$targetPath")" == $homeFilePattern ]] ; then
# The target file already exists and it isn't a symlink owned by Home Manager.
if cmp -s "$sourcePath" "$targetPath"; then
# First compare the files' content. If they're equal, we're fine.
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be skipped since they are the same"
elif [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
# Next, try to move the file to a backup location if configured and possible
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT"
if [[ -e "$backup" ]]; then
errorEcho "Existing file '$backup' would be clobbered by backing up '$targetPath'"
collision=1
else
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be moved to '$backup'"
fi
else
# Fail if nothing else works
errorEcho "Existing file '$targetPath' is in the way of '$sourcePath'"
collision=1
fi
fi
done

if [[ -v collision ]] ; then
errorEcho "Please move the above files and try again or use 'home-manager switch -b backup' to back up existing files automatically."
exit 1
fi
12 changes: 12 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
githubId = 32838899;
name = "Daniel Wagenknecht";
};
jack5079 = {
name = "Jack W.";
email = "[email protected]";
github = "jack5079";
githubId = 29169102;
};
jkarlson = {
email = "[email protected]";
github = "jkarlson";
Expand Down Expand Up @@ -512,4 +518,10 @@
github = "zorrobert";
githubId = 118135271;
};
diniamo = {
name = "diniamo";
email = "[email protected]";
github = "diniamo";
githubId = 55629891;
};
}
14 changes: 14 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,20 @@ in {
A new module is available: 'services.activitywatch'.
'';
}

{
time = "2024-03-24T20:58:23+00:00";
message = ''
A new module is available: 'programs.spotify-player'.
'';
}

{
time = "2024-04-08T21:43:38+00:00";
message = ''
A new module is available: 'programs.bun'.
'';
}
];
};
}
2 changes: 2 additions & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ let
./programs/broot.nix
./programs/browserpass.nix
./programs/btop.nix
./programs/bun.nix
./programs/carapace.nix
./programs/cava.nix
./programs/chromium.nix
Expand Down Expand Up @@ -209,6 +210,7 @@ let
./programs/sioyek.nix
./programs/skim.nix
./programs/sm64ex.nix
./programs/spotify-player.nix
./programs/sqls.nix
./programs/ssh.nix
./programs/starship.nix
Expand Down
59 changes: 59 additions & 0 deletions modules/programs/bun.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:

let
cfg = config.programs.bun;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ lib.hm.maintainers.jack5079 ];

options.programs.bun = {
enable = lib.mkEnableOption "Bun JavaScript runtime";

package = lib.mkPackageOption pkgs "bun" { };

settings = lib.mkOption {
type = tomlFormat.type;
default = { };
example = lib.literalExpression ''
{
smol = true;
telemetry = false;
test = {
coverage = true;
coverageThreshold = 0.9;
};
install.lockfile = {
print = "yarn";
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/.bunfig.toml`.
See <https://bun.sh/docs/runtime/bunfig>
for the full list of options.
'';
};

enableGitIntegration = lib.mkEnableOption "Git integration" // {
default = true;
};
};

config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile.".bunfig.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "bun-config" cfg.settings;
};

# https://bun.sh/docs/install/lockfile#how-do-i-git-diff-bun-s-lockfile
programs.git.attributes =
lib.mkIf cfg.enableGitIntegration [ "*.lockb binary diff=lockb" ];
programs.git.extraConfig.diff.lockb = lib.mkIf cfg.enableGitIntegration {
textconv = lib.getExe cfg.package;
binary = true;
};
};
}
12 changes: 12 additions & 0 deletions modules/programs/firefox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,17 @@ in {
};
};

containersForce = mkOption {
type = types.bool;
default = false;
description = ''
Whether to force replace the existing containers
configuration. This is recommended since Firefox will
replace the symlink on every launch, but note that you'll
lose any existing configuration by enabling this.
'';
};

containers = mkOption {
type = types.attrsOf (types.submodule ({ name, ... }: {
options = {
Expand Down Expand Up @@ -762,6 +773,7 @@ in {

"${profilesPath}/${profile.path}/containers.json" =
mkIf (profile.containers != { }) {
force = profile.containersForce;
text = mkContainersJson profile.containers;
};

Expand Down
4 changes: 2 additions & 2 deletions modules/programs/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,14 @@ in {
${cfg.shellInit}
status --is-login; and begin
status is-login; and begin
# Login shell initialisation
${cfg.loginShellInit}
end
status --is-interactive; and begin
status is-interactive; and begin
# Abbreviations
${abbrsStr}
Expand Down
1 change: 1 addition & 0 deletions modules/programs/foot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ in {
};

Service = {
Environment = "PATH=${makeBinPath [ cfg.package ]}";
ExecStart = "${cfg.package}/bin/foot --server";
Restart = "on-failure";
OOMPolicy = "continue";
Expand Down
53 changes: 36 additions & 17 deletions modules/programs/fzf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,35 @@ let
concatStringsSep ","
(mapAttrsToList (name: value: "${name}:${value}") colors);

hasShellIntegrationEmbedded = lib.versionAtLeast cfg.package.version "0.48.0";

bashIntegration = if hasShellIntegrationEmbedded then ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
eval "$(${getExe cfg.package} --bash)"
fi
'' else ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
. ${cfg.package}/share/fzf/completion.bash
. ${cfg.package}/share/fzf/key-bindings.bash
fi
'';

zshIntegration = if hasShellIntegrationEmbedded then ''
if [[ $options[zle] = on ]]; then
eval "$(${getExe cfg.package} --zsh)"
fi
'' else ''
if [[ $options[zle] = on ]]; then
. ${cfg.package}/share/fzf/completion.zsh
. ${cfg.package}/share/fzf/key-bindings.zsh
fi
'';

fishIntegration = if hasShellIntegrationEmbedded then ''
${getExe cfg.package} --fish | source
'' else ''
source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings
'';
in {
imports = [
(mkRemovedOptionModule [ "programs" "fzf" "historyWidgetCommand" ]
Expand Down Expand Up @@ -173,26 +202,16 @@ in {
# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence.
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
. ${cfg.package}/share/fzf/completion.bash
. ${cfg.package}/share/fzf/key-bindings.bash
fi
'');
programs.bash.initExtra =
mkIf cfg.enableBashIntegration (mkOrder 200 bashIntegration);

# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence.
programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200 ''
if [[ $options[zle] = on ]]; then
. ${cfg.package}/share/fzf/completion.zsh
. ${cfg.package}/share/fzf/key-bindings.zsh
fi
'');

programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
(mkOrder 200 ''
source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings
'');
programs.zsh.initExtra =
mkIf cfg.enableZshIntegration (mkOrder 200 zshIntegration);

programs.fish.interactiveShellInit =
mkIf cfg.enableFishIntegration (mkOrder 200 fishIntegration);
};
}
Loading

0 comments on commit f072b47

Please sign in to comment.