Hi,
I have my NixOS config in a flake. I have some custom derivations that I want to extract as independent flakes on GitHub and then use in my config. After some trial and error and searching, I did not solve it yet. This can’t be! This should be pretty default, hence I request your kind help
My current config is as follows (with flake.nix
loading the module home.nix
which in turn imports the module audio.nix
):
# flake.nix shortened
{
description = "my nixos";
inputs = ...
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
in
{
nixosConfigurations.myhost =
let
bla = "blub";
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit bla; };
modules = [
...
./configuration.nix
home-manager.nixosModules.home-manager
./home.nix
];
};
...
};
...
}
# home.nix shortened
{ username, uid, ... }: {
...
home-manager.users.${username} = {
programs.home-manager.enable = false;
home = {
stateVersion = "23.05";
inherit username;
homeDirectory = "/home/${username}";
};
imports = [
...
../../home-manager/audio.nix
...
];
};
}
and
# audio.nix shortened
{ config, pkgs, ... }:
let
...
in
let
camilladsp = mkDerivation {
name = "camilladsp";
src = fetchzip {
url = "https://github.com/HEnquist/camilladsp/releases/download/v1.0.3/camilladsp-linux-amd64.tar.gz";
hash = "sha256-zWOyPmaHRi2VIRvzFpS02tPlXNn90ogU2Q/YRx7l6eI=";
};
phases = [
"installPhase"
"preFixup"
];
installPhase = ''
install -D $src/camilladsp $out/bin/camilladsp
'';
preFixup =
let
libPath = lib.makeLibraryPath [
alsaLib
pulseaudio
];
in
''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath}" \
$out/bin/camilladsp
'';
};
in
{
home.packages = [
camilladsp
... # more custom derivations here
];
...
}
It all works. (Please don’t mind the folder structure. I’m currently refactoring to a flake and the folder structure are WIP.) Extracting camilladsp into a package of a separate flake, my goal is to
- add it to the inputs of my current flake (i tried already and
nix flake check
succeeded) - pass the package on to
audio.nix
(throughhome.nix
)
That passing the package on is where I fail. Does anybody have a pointer or example of how to achieve this? Should I take a totally different approach?
Thanks in advance!