packages: convert to self-contained flake-parts modules

Each package file now exports its own perSystem.packages.<name> definition
instead of being called from a centralized packages.nix file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
William 2026-02-07 07:54:49 -03:00
parent 1b7ea7e59b
commit 829fde6a3a
6 changed files with 459 additions and 445 deletions

View file

@ -1,13 +1,14 @@
{ ... }:
{
lib,
stdenv,
fetchFromGitHub,
}:
stdenv.mkDerivation (finalAttrs: {
perSystem =
{ pkgs, ... }:
{
packages.base16-schemes = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "base16-schemes";
version = "0-unstable-2025-06-04";
src = fetchFromGitHub {
src = pkgs.fetchFromGitHub {
owner = "tinted-theming";
repo = "schemes";
rev = "317a5e10c35825a6c905d912e480dfe8e71c7559";
@ -26,7 +27,9 @@ stdenv.mkDerivation (finalAttrs: {
meta = {
description = "All the color schemes for use in base16 packages";
homepage = "https://github.com/tinted-theming/schemes";
maintainers = [ lib.maintainers.DamienCassou ];
license = lib.licenses.mit;
maintainers = [ pkgs.lib.maintainers.DamienCassou ];
license = pkgs.lib.licenses.mit;
};
})
});
};
}

View file

@ -1,31 +1,25 @@
{ inputs, ... }:
{
lib,
stdenv,
fetchurl,
makeWrapper,
makeDesktopItem,
copyDesktopItems,
p7zip,
unzip,
electron,
nodejs,
asar,
graphicsmagick,
}:
perSystem =
{ system, ... }:
let
pname = "claude-desktop";
version = "1.0.1768"; # Updated based on extracted nupkg
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
srcs.x86_64-linux = fetchurl {
pname = "claude-desktop";
version = "1.0.1768";
srcs.x86_64-linux = pkgs.fetchurl {
url = "https://downloads.claude.ai/releases/win32/x64/1.0.1768/Claude-67d01376d0e9d08b328455f6db9e63b0d603506a.exe";
hash = "sha256-x76Qav38ya3ObpWIq3dDowo79LgvVquMfaZeH8M1LUk=;";
};
src =
srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
srcs.${pkgs.stdenv.hostPlatform.system} or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}");
# Stub implementation for claude-native module
claudeNativeStub = ''
// Stub implementation of claude-native using KeyboardKey enum values
const KeyboardKey = {
@ -50,12 +44,12 @@ let
KeyboardKey
};
'';
in
stdenv.mkDerivation rec {
{
packages.claude-desktop = pkgs.stdenv.mkDerivation rec {
inherit pname version src;
nativeBuildInputs = [
nativeBuildInputs = with pkgs; [
makeWrapper
copyDesktopItems
p7zip
@ -64,12 +58,10 @@ stdenv.mkDerivation rec {
graphicsmagick
];
buildInputs = [
electron
];
buildInputs = [ pkgs.electron ];
desktopItems = [
(makeDesktopItem {
(pkgs.makeDesktopItem {
name = "claude-desktop";
desktopName = "Claude";
comment = "AI assistant from Anthropic";
@ -101,7 +93,7 @@ stdenv.mkDerivation rec {
# Extract app.asar to modify it
if [ -f ./nupkg/lib/net45/resources/app.asar ]; then
echo "Extracting app.asar..."
${asar}/bin/asar extract ./nupkg/lib/net45/resources/app.asar ./app
${pkgs.asar}/bin/asar extract ./nupkg/lib/net45/resources/app.asar ./app
# Also copy the unpacked resources
if [ -d ./nupkg/lib/net45/resources/app.asar.unpacked ]; then
@ -158,7 +150,7 @@ stdenv.mkDerivation rec {
# Repack the modified app as app.asar
cd ./app
${asar}/bin/asar pack . ../app.asar
${pkgs.asar}/bin/asar pack . ../app.asar
cd ..
# Copy resources
@ -179,7 +171,7 @@ stdenv.mkDerivation rec {
fi
# Create wrapper script
makeWrapper ${electron}/bin/electron $out/bin/claude-desktop \
makeWrapper ${pkgs.electron}/bin/electron $out/bin/claude-desktop \
--add-flags "$out/lib/claude-desktop/resources/app.asar" \
--set DISABLE_AUTOUPDATER 1 \
--set NODE_ENV production
@ -209,13 +201,15 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
meta = with lib; {
meta = with pkgs.lib; {
description = "Claude Desktop - AI assistant from Anthropic";
homepage = "https://claude.ai";
license = licenses.unfree;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
maintainers = with maintainers; [ ];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
maintainers = [ ];
platforms = [ "x86_64-linux" ];
mainProgram = "claude-desktop";
};
};
};
}

View file

@ -1,8 +1,8 @@
{
lib,
pkgs ? import <nixpkgs> { },
}:
{ ... }:
{
perSystem =
{ pkgs, lib, ... }:
let
fastfetch-logo = pkgs.fetchurl {
url = "https://discourse.nixos.org/uploads/default/original/3X/3/6/36954e6d6aa32c8b00f50ca43f142d898c1ff535.png";
@ -78,4 +78,7 @@ let
}
);
in
pkgs.writeShellScriptBin "fastfetch" ''exec ${lib.getExe pkgs.fastfetch} --config ${fastfetch-config} --logo-type kitty --logo ${fastfetch-logo} --logo-padding-right 1 --logo-width 36 "$@" ''
{
packages.fastfetch = pkgs.writeShellScriptBin "fastfetch" ''exec ${lib.getExe pkgs.fastfetch} --config ${fastfetch-config} --logo-type kitty --logo ${fastfetch-logo} --logo-padding-right 1 --logo-width 36 "$@" '';
};
}

View file

@ -1,8 +1,10 @@
{
pkgs ? import <nixpkgs> { },
}:
{ ... }:
pkgs.writeShellScriptBin "hm" ''
{
perSystem =
{ pkgs, ... }:
{
packages.hm-cli = pkgs.writeShellScriptBin "hm" ''
set -e
HM="${pkgs.lib.getExe pkgs.home-manager}"
@ -102,4 +104,6 @@ pkgs.writeShellScriptBin "hm" ''
exit 1
;;
esac
''
'';
};
}

View file

@ -1,6 +1,10 @@
{ pkgs }:
{ ... }:
pkgs.symlinkJoin {
{
perSystem =
{ pkgs, ... }:
{
packages.kwrite = pkgs.symlinkJoin {
name = "kwrite";
paths = [ pkgs.kdePackages.kate ];
postBuild = ''
@ -12,4 +16,6 @@ pkgs.symlinkJoin {
$out/share/icons/hicolor/scalable/apps/kate.svg \
$out/share/appdata/org.kde.kate.appdata.xml
'';
};
};
}

View file

@ -1,8 +1,10 @@
{
pkgs ? import <nixpkgs> { },
}:
{ ... }:
pkgs.writeShellScriptBin "toggleaudiosink" ''
{
perSystem =
{ pkgs, ... }:
{
packages.toggleaudiosink = pkgs.writeShellScriptBin "toggleaudiosink" ''
#!/usr/bin/env bash
sound_server="pipewire"
@ -45,4 +47,6 @@ pkgs.writeShellScriptBin "toggleaudiosink" ''
for app in $(${pkgs.pulseaudio}/bin/pactl list sink-inputs | sed -n -e 's/.*Sink Input #\([[:digit:]]\)/\1/p'); do
${pkgs.pulseaudio}/bin/pactl "move-sink-input $app $next_sink"
done
''
'';
};
}