Manually installing package

Hi

I was hoping someone could help with an installation on Nixos.
I’ve tried reading the manual, and some pills and Google/Youtube without luck.
After using Mint for some years I have decided to try Nixos, and after 2 days I have been able to install and run Nixos.
But I cant figure out how to install my own package, a theme for XFCE.
Do anyone know how I can do this easily?
I’m not that good with codes, but trying to get there.

Currently my theme is located at
/home/Anna/Templates/Dream/Dream Light/

I can’t find the theme folder at all, most of my config is read or found on Youtube, here is it under:

Anna / MiniKnott

configuration.nix

October 2020

{ config, pkgs, … }:

{
imports =
[ # Hardware
./hardware-configuration.nix
];

Systemd-boot EFI boot

boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;

Hostname

networking.hostName = “MiniKnott”;

Networking.

networking.networkmanager.enable = true;

networking.useDHCP = false;
networking.interfaces.enp0s25.useDHCP = true;
networking.interfaces.wlp3s0.useDHCP = true;

Set your time zone.

time.timeZone = “Europe/Stockholm”;

Flatpak

services.flatpak.enable = true;
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

Proprietary

nixpkgs.config.allowUnfree = true;

Packages

$ nix search wget

environment.systemPackages = with pkgs; [
wget

System

 microcodeIntel
 lm_sensors
 xarchiver
 zip
 unzip
 unrar
 ranger
 dmenu
 htop

Online

 chromium
 tdesktop
 transmission-gtk

Office

 atom
 nano
 libreoffice-still
 zathura
 gimp
 blender

Entertainment

 vlc
 gpodder
 deadbeef
 bookworm

Games

 ppsspp

Junk

 neofetch
# plank

Themes

 yaru-theme
 adapta-gtk-theme

];

Fonts

fonts.fonts = with pkgs; [
source-code-pro
];

Firewall

networking.firewall.enable = false;

Print

services.printing.enable = true;

Sound.

sound.enable = true;
hardware.pulseaudio.enable = true;

Enable the X11

services.xserver.enable = true;
services.xserver.layout = “us”;
services.xserver.xkbOptions = “eurosign:e”;

Enable touchpad

services.xserver.libinput.enable = true;

Enable the Desktop

services.xserver.displayManager.lightdm.enable = true;
services.xserver.desktopManager.xfce.enable = true;

Don’t forget ‘passwd’.

users.users.anna = {
isNormalUser = true;
extraGroups = [ “wheel” “networkmanager” ]; # Enable ‘sudo’ for the user.
};

system.stateVersion = “20.03”; # Did you read the comment?

}

You would typically create a Nix package for the theme.

  1. Create a Nix file like the following (named, for example, my-theme.nix in a pkgs directory next to the configuration.nix):
  1. In the file, set the src to either the GitHub repo with your theme (using fetchFromGitHub) or to the directory with your theme src = /home/Anna/Templates/Dream;. I am not sure where are Xfce themes installed, you might need to tweak the installation directories in the installPhase too.

  2. In your configuration.nix add (pkgs.callPackage ./pkgs/my-theme.nix { }) to your environment.systemPackages. That will pass all the dependencies to the package and allow install it globally.

Depending on the path to themes you might also need to add environment.pathsToLink = [ "/share/wherever/xfce/stores/themes" ]; option to your configuration.

1 Like

Thank you.
this distro is a lot harder than i expected, but it actually run fine with all my usual stuff
ive started on what you wrote
I’ve made my dream.nix and placed it in /etc/nixos/

The file: dreamlight.nix

{ stdenv, fetchurl, gtk-engine-murrine }:

let
themeName = “Dreamlight”;
in
stdenv.mkDerivation rec {
pname = “dreamlight-theme”;
version = “1.0”;

src = /home/Anna/Templates/Dream;

propagatedUserEnvPkgs = [
gtk-engine-murrine
];

installPhase = ‘’
runHook preInstall

do you know if it looks right?

on environment.pathsToLink = [ “/share/wherever/xfce/stores/themes” ];
can i use the same as mint xfce?
that was /usr/share/theme so for example: /share/user/share/theme/store/themes?

im afraid of getting it wrong, because i have reformated my pc 9 times while getting this far, i would rather not do that again if im able to.
Getting good at installing nixos at least

If Mint stored themes in /usr/share/theme, you would use environment.pathsToLink = [ "/share/theme" ];.

I suspect the part

propagatedUserEnvPkgs = [
gtk-engine-murrine
];

might not be necessary unless it is a GTK 2 theme.

But looks like you copied just the truncated part Discourse inlined into the post, you will want to use the rest of the whole file too.

It should not really be necessary to reformat once you install NixOS. You can just change your configuration.nix and use nixos-rebuild switch to build the system from the updated configuration, or even nixos-rebuild switch --rollback if something goes terribly wrong.

Also if you select the source code on Discourse and click this button, image it will get correctly formatted as source code.

Thank you again :slight_smile:

I didn’t know I could use --rollback
will use that from now on.

I copied the whole file and added it to nix, but in the same folder as the configuration.nix is that fine or do i need to make the pkg folder? because i don’t have it.
Other than that I’m getting an error when running nixos-rebuild switch
I have this in my config:

Theme Test

environment.pathsToLink = [ “/share/theme” ];
pkgs.callPackage ./dreamlight.nix { }(

Packages

$ nix search wget

environment.systemPackages = with pkgs; [
wget

this is the error i get:
error: syntax error, unexpected ‘(’, at /etc/nixos/configuration.nix:41:4

my complete file for the theme:

{ stdenv, fetchurl, gtk-engine-murrine }:

let
themeName = “Dreamlight”;
in
stdenv.mkDerivation rec {
pname = “dreamlight-theme”;
version = “1.3.0”;

src = /home/Anna/Templates/Dreamlight;

propagatedUserEnvPkgs = [
gtk-engine-murrine
];

installPhase = ‘’
runHook preInstall
mkdir -p out/share/themes/{themeName}
cp -a * out/share/themes/{themeName}
rm -r out/share/themes/{themeName}/{Art,LICENSE,README.md,gtk-2.0/render-assets.sh}
runHook postInstall
‘’;

meta = with stdenv.lib; {
description = “A flat and light theme with a modern look”;
homepage = “https://github.com/EliverLara/${themeName}”;
license = licenses.gpl3;
platforms = platforms.all;
maintainers = with maintainers; [ alexarice ];
};
}

Yes, same directory is fine. Placing it in pkgs is only a convention intended to make the directory cleaner when you have a lot of packages. But Nix does not really care where the file is located, as long as a correct path is used to import it.

This line should be (pkgs.callPackage ./dreamlight.nix { }) (parentheses are important so that Nix knows it is a single expression) and should be in environment.systemPackages list, since it is a function call that returns a package (derivation).

Also please use the image button when posting configuration here, it will be much easier to read.

I don’t quite understand what this means.

should be in environment.systemPackages list

This is what my config file is now

#                               Anna / MiniKnott
#                              configuration.nix
#                                October 2020

{ config, pkgs, ... }:

{
  imports =
    [ # Hardware
      ./hardware-configuration.nix
    ];

  # Systemd-boot EFI boot
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Hostname
  networking.hostName = "MiniKnott";

  # Networking.
  networking.networkmanager.enable = true;

  networking.useDHCP = false;
  networking.interfaces.enp0s25.useDHCP = true;
  networking.interfaces.wlp3s0.useDHCP = true;


  # Set your time zone.
   time.timeZone = "Europe/Stockholm";

  # Flatpak
   services.flatpak.enable = true;
   xdg.portal.enable = true;
   xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

  # Proprietary
   nixpkgs.config.allowUnfree = true;

  # Theme Test
   environment.pathsToLink = [ "/share/theme" ];

  # Packages
  # $ nix search wget
   environment.systemPackages = with pkgs; [
    (pkgs.callPackage ./dreamlight.nix { }(
   #  System
     wget
     microcodeIntel
     lm_sensors
     xarchiver
     zip
     unzip
     unrar
     ranger
     dmenu
     htop
   #  Online
     chromium
     tdesktop
     transmission-gtk
   #  Office
     atom
     nano
     libreoffice-still
     zathura
     gimp
     blender
  #   Entertainment
     vlc
     gpodder
     deadbeef
     bookworm
  #   Games
     ppsspp
  #   Junk
     neofetch
    # plank
  #   Themes
     yaru-theme
     adapta-gtk-theme
   ];

  # Fonts
   fonts.fonts = with pkgs; [
     source-code-pro
   ];


  # Firewall
   networking.firewall.enable = false;

  # Print
   services.printing.enable = true;

  # Sound.
   sound.enable = true;
   hardware.pulseaudio.enable = true;

  # Enable the X11
   services.xserver.enable = true;
   services.xserver.layout = "us";
   services.xserver.xkbOptions = "eurosign:e";

  # Enable touchpad
   services.xserver.libinput.enable = true;

  # Enable the Desktop
   services.xserver.displayManager.lightdm.enable = true;
   services.xserver.desktopManager.xfce.enable = true;

  # Don't forget ‘passwd’.
   users.users.anna = {
     isNormalUser = true;
     extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user.
   };

  #
  system.stateVersion = "20.03"; # Did you read the comment?

}

And again, thank you so much for your help. This whole thing is more difficult than I expected, but I’m learning. Trying at least :sweat_smile:

This is almost good, you just have an opening bracket instead of a closing at the end of the line. It should be (pkgs.callPackage ./dreamlight.nix { })

Started installing but got a new error:
Do this say anything on where im wrong?

[root@MiniKnott:/home/anna]# nixos-rebuild switch
building Nix...
building the system configuration...
these derivations will be built:
  /nix/store/m26phdb5akvxkc65h6jianrmp0i45n60-dreamlight-1.3.0.drv
  /nix/store/1064s2dvvv6nl2z9zny18ajgp3pb3bj4-system-path.drv
  /nix/store/hzv52p5qrcs1q2cvm816ybicwixyarn5-dbus-1.drv
  /nix/store/8bjdy0s6gipb2r6242g16dmsdym2xgzy-unit-dbus.service.drv
  /nix/store/i5jgymm98pq68s7mm4057pwbk3q4dx8d-user-units.drv
  /nix/store/qv82vpy1j5nayy55ypc4h89z0dk8mpw2-unit-accounts-daemon.service.drv
  /nix/store/qyi2gscgvhkrisb6i2jvk6l2lbawyi8k-unit-polkit.service.drv
  /nix/store/sh29vc61a762pna2dnqvhqmrgwpaikzd-unit-dbus.service.drv
  /nix/store/vx2cwd3ri702s0pl7whxlszj3dhar7x3-unit-systemd-fsck-.service.drv
  /nix/store/jhk4r0jzxls8w5ppvjq1zxa2kpkna758-system-units.drv
  /nix/store/kbynbv34001c7p38xnhy0k6wvz7551yn-etc.drv
  /nix/store/4ym1qa9gsbr2y722bk1xdzl7csfk6p9q-nixos-system-MiniKott-20.09beta1057.0b8799ecaaf.drv
building '/nix/store/m26phdb5akvxkc65h6jianrmp0i45n60-dreamlight-theme-1.3.0.drv'...
unpacking sources
unpacking source archive /nix/store/c5lzz45qzkqwwpf0d85zz26kgv9cmz4n-dreamlight
source root is dreamlight
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
rm: cannot remove '/nix/store/v58n3glq1r8br6p1dlhg1mrh34bph9ja-dreamlight-theme-1.3.0/share/themes/dreamlight/Art': No such file or directory
rm: cannot remove '/nix/store/v58n3glq1r8br6p1dlhg1mrh34bph9ja-dreamlight-theme-1.3.0/share/themes/dreamlight/LICENSE': No such file or directory
rm: cannot remove '/nix/store/v58n3glq1r8br6p1dlhg1mrh34bph9ja-dreamlight-theme-1.3.0/share/themes/dreamlight/README.md': No such file or directory
rm: cannot remove '/nix/store/v58n3glq1r8br6p1dlhg1mrh34bph9ja-dreamlight-theme-1.3.0/share/themes/dreamlight/gtk-2.0/render-assets.sh': No such file or directory
builder for '/nix/store/m26phdb5akvxkc65h6jianrmp0i45n60-dreamlight-theme-1.3.0.drv' failed with exit code 1
cannot build derivation '/nix/store/1064s2dvvv6nl2z9zny18ajgp3pb3bj4-system-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/4ym1qa9gsbr2y722bk1xdzl7csfk6p9q-nixos-system-MiniKnott-20.09beta1057.0b8799ecaaf.drv': 1 dependencies couldn't be built
error: build of '/nix/store/4ym1qa9gsbr2y722bk1xdzl7csfk6p9q-nixos-system-MiniKnott-20.09beta1057.0b8799ecaaf.drv' failed`Preformatted text`

This is the error:

You will need to adjust the installPhase to match the files in your package.

As it says near the bottom of the output, nix fails to remove some files because they do not exist. There is a rm -r $out/share/themes/${themeName}/{Art,LICENCE,README,gtk-2.0/render-assets.h} line in the installPhase that does this. Try removing that line, since it does not seem to be essential for the working of the theme that those files are deleted.

I finally got it to work. I want to thank everyone for their help! I don’t think I would have figured it out on my own. Thank you!

When packaging stuff, if you need to debug the build process, the -K flag lets you inspect the state of the build directory when the failure happened. Try running nixos-rebuild build -K with your failing config; nixos-rebuild will tell you which package failed to build and give you the location where it left the buid directory, so that you can inspect it. If you want to try and run the build process by hand from there, there are a few commands to run, but I’m net sure where they are documented.

1 Like