Conversation
adds a module for wallpaper and colours for darwin
|
So, i've never made a module for stylix, and i'm getting some errors to do with callPackage not existing, and unsure if my shellScript outputs correctly but i'm unsure how i even test this? |
There was a problem hiding this comment.
this should probably go under /stylix/darwin/ instead of /modules/darwin/
i'm getting some errors to do with callPackage not existing
this is probably due to the doc eval, cc @MattSturgeon
|
the entire thing? or just the desktoppr? |
modules/darwin/hm.nix
Outdated
| extraOptions = | ||
| { | ||
| image, | ||
| }: | ||
| { | ||
| home.activation = { | ||
| stylixBackground = '' | ||
| run ${pkgs.callPackage ./desktoppr.nix { }}/bin/desktoppr all ${image} | ||
|
|
||
| ''; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
i'm getting some errors to do with callPackage not existing
this is probably due to the doc eval, cc @MattSturgeon
extraOptions is for declaring options. You haven't used lib.mkOption or any of its wrappers, so this looks a lot more like a config definition that should go in configElements.
The reason pkgs.callPackage doesn't exist when declaring options is to ensure it is not accidentally used in option docs (i.e. option examples, defaultText, etc). See #1212
Could you clarify what you're trying to achieve here?
You may find Writing NixOS Modules helpful, in particular the distinction between declaring and defining options.
There was a problem hiding this comment.
i'm familiar with the distinction and have written many modules, i was just very unsure how this mkStylixModule system works
There was a problem hiding this comment.
Understandable. Too many layers of abstraction can make it difficult to understand what things actually do.
There was a problem hiding this comment.
i'm familiar with the distinction and have written many modules, i was just very unsure how this mkStylixModule system works
Did you already take a look at
Lines 42 to 115 in 0ce0103
Understandable. Too many layers of abstraction can make it difficult to understand what things actually do.
Yes, the mkTarget documentation is currently too technical and the implementation is too complex to quickly understand. Once the mkTarget behavior has further solidified after merging #1721, improving the documentation is planned. Note that the currently pending commit 300f48d ("stylix/mk-target: polish implementation and improve error reporting") from #1721 attempts to improve and drastically simplify the implementation.
Aside from the mkTarget documentation, take a look at existing mkTarget examples in /modules/<MODULE>/.
modules/darwin/hm.nix
Outdated
| full=$((16#${colors.base00})) | ||
| red=$((($full >> 16) & 0xff)) | ||
| red=$(echo "scale=10; $red.0 / 255.0 " | bc |awk '{printf "%f", $0}') |
There was a problem hiding this comment.
Note: the indentation seems off here:
| full=$((16#${colors.base00})) | |
| red=$((($full >> 16) & 0xff)) | |
| red=$(echo "scale=10; $red.0 / 255.0 " | bc |awk '{printf "%f", $0}') | |
| full=$((16#${colors.base00})) | |
| red=$((($full >> 16) & 0xff)) | |
| red=$(echo "scale=10; $red.0 / 255.0 " | bc |awk '{printf "%f", $0}') |
modules/darwin/hm.nix
Outdated
| in | ||
| { | ||
|
|
||
| targets.darwin.defaults."Apple Global Domain".AppleIconAppearanceCustomTintColor = value; |
There was a problem hiding this comment.
I don't understand why you would bind the color package to value in a let block, but then only use it once.
Why not just bind it directly here in the config definition? I.e. inline value.
| { | ||
| stdenv, | ||
| fetchurl, | ||
| lib, | ||
| unzip, | ||
| }: | ||
| stdenv.mkDerivation { | ||
| name = "desktoppr"; | ||
| version = "0.5-218"; | ||
| pname = "desktoppr"; | ||
| src = fetchurl { | ||
| url = "https://github.com/scriptingosx/desktoppr/releases/download/v0.5/desktoppr-0.5-218.zip"; | ||
| hash = "sha256-Oa9gAQjOaJHYyT5JBUiFCxL1sQP1dqlFBm+GdmLHNNM="; | ||
| }; | ||
|
|
||
| buildInputs = [ | ||
| unzip | ||
| ]; | ||
|
|
||
| unpackPhase = '' | ||
| runHook preUnpack | ||
|
|
||
| unzip $src | ||
|
|
||
| runHook postUnpack | ||
| ''; | ||
|
|
||
| installPhase = '' | ||
| runHook preInstall | ||
|
|
||
| mkdir -p $out/bin | ||
| cp -r desktoppr $out/bin | ||
|
|
||
| runHook postInstall | ||
| ''; | ||
|
|
||
| } |
There was a problem hiding this comment.
This pr might be worth mentioning NixOS/nixpkgs#397284
There was a problem hiding this comment.
This pr might be worth mentioning NixOS/nixpkgs#397284
Thanks for pointing that out. I suggest using the Nixpkgs module (after updating our Nixpkgs input) once it has been merged.
| { | ||
| stdenv, | ||
| fetchurl, | ||
| lib, | ||
| unzip, | ||
| }: | ||
| stdenv.mkDerivation { | ||
| name = "desktoppr"; | ||
| version = "0.5-218"; | ||
| pname = "desktoppr"; | ||
| src = fetchurl { | ||
| url = "https://github.com/scriptingosx/desktoppr/releases/download/v0.5/desktoppr-0.5-218.zip"; | ||
| hash = "sha256-Oa9gAQjOaJHYyT5JBUiFCxL1sQP1dqlFBm+GdmLHNNM="; | ||
| }; | ||
|
|
||
| buildInputs = [ | ||
| unzip | ||
| ]; | ||
|
|
||
| unpackPhase = '' | ||
| runHook preUnpack | ||
|
|
||
| unzip $src | ||
|
|
||
| runHook postUnpack | ||
| ''; | ||
|
|
||
| installPhase = '' | ||
| runHook preInstall | ||
|
|
||
| mkdir -p $out/bin | ||
| cp -r desktoppr $out/bin | ||
|
|
||
| runHook postInstall | ||
| ''; | ||
|
|
||
| } |
There was a problem hiding this comment.
This pr might be worth mentioning NixOS/nixpkgs#397284
Thanks for pointing that out. I suggest using the Nixpkgs module (after updating our Nixpkgs input) once it has been merged.
| { | ||
| name = "Darwin"; | ||
| homepage = "https://github.com/nix-darwin/nix-darwin"; | ||
| maintainers = [ ]; |
modules/darwin/hm.nix
Outdated
| extraOptions = | ||
| { | ||
| image, | ||
| }: | ||
| { | ||
| home.activation = { | ||
| stylixBackground = '' | ||
| run ${pkgs.callPackage ./desktoppr.nix { }}/bin/desktoppr all ${image} | ||
|
|
||
| ''; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
i'm familiar with the distinction and have written many modules, i was just very unsure how this mkStylixModule system works
Did you already take a look at
Lines 42 to 115 in 0ce0103
Understandable. Too many layers of abstraction can make it difficult to understand what things actually do.
Yes, the mkTarget documentation is currently too technical and the implementation is too complex to quickly understand. Once the mkTarget behavior has further solidified after merging #1721, improving the documentation is planned. Note that the currently pending commit 300f48d ("stylix/mk-target: polish implementation and improve error reporting") from #1721 attempts to improve and drastically simplify the implementation.
Aside from the mkTarget documentation, take a look at existing mkTarget examples in /modules/<MODULE>/.
| pkgs.runCommand "color" { } '' | ||
| full=$((16#${colors.base00})) | ||
| red=$((($full >> 16) & 0xff)) | ||
| red=$(echo "scale=10; $red.0 / 255.0 " | bc |awk '{printf "%f", $0}') | ||
| green=$((($full >> 8) & 0xff)) | ||
| green=$(echo "scale=10; $green.0 / 255.0 " | bc | awk '{printf "%f", $0}') | ||
| blue=$(($full & 0xff)) | ||
| blue=$(echo "scale=10; $blue.0 / 255.0 " | bc | awk '{printf "%f", $0}') | ||
| echo "$red $green $blue 1.0" > $out | ||
| '' |
There was a problem hiding this comment.
It would be better to natively implement this in Nix. Also, take a look at existing Stylix modules, to find something similar as inspiration.
There was a problem hiding this comment.
Like in colors.nix module that was recently merged for mkHexOpacityColor and mkHexColor
adds a module for wallpaper and colours for darwin