19 Aug 2024 |
Šimon Brandner | Nope, it's a simple: oblichey.url = "git+file:///home/simon/GIT/Rust/oblichey"; | 08:04:46 |
Šimon Brandner | I wonder if this is somehow related to a bug I had some time ago: https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit/issues/7 | 08:05:01 |
blitz | Can you post a complete failing example? | 08:06:51 |
Šimon Brandner | Sure!
App flake.nix :
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {nixpkgs, ...}: let
pkgs = import nixpkgs {system = "x86_64-linux";};
in {
packages.x86_64-linux = {
default = nixpkgs.legacyPackages.${"x86_64-linux"}.callPackage ./nix/package.nix {inherit pkgs;};
devShells.default = import ./nix/shell.nix;
};
nixosModules.default = import ./nix/module.nix;
};
}
package.nix :
{
lib,
pkgs,
}: let
cargoTomlPath = ../Cargo.toml;
cargoTomlContent = builtins.fromTOML (builtins.readFile cargoTomlPath);
in
pkgs.rustPlatform.buildRustPackage rec {
pname = "oblichey";
version = cargoTomlContent.workspace.package.version;
src = lib.cleanSource ../.;
cargoToml = cargoTomlPath;
cargoLock = {
lockFile = ../Cargo.lock;
outputHashes = {
"burn-0.14.0" = "sha256-ChBlLKeq0WuINP+6mfZ0vFMYOKWnqT2dEMuM0UZJnbc=";
"cubecl-0.1.1" = "sha256-tLNC2KRRYrRRKL9HkhTYHg8tvxkJDm9fM8GrSQWNXeM=";
};
};
nativeBuildInputs = with pkgs; [
clang
fontconfig
pkg-config
libxkbcommon
libGL
cmake
wayland
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
vulkan-headers
vulkan-loader
rustfmt
];
buildInputs = with pkgs; [
fontconfig
vulkan-headers
vulkan-loader
pam
];
preInstall = ''
mkdir -p $out/bin
cp -r target/x86_64-unknown-linux-gnu/release/weights $out/bin/weights
'';
postFixup = ''
patchelf --add-rpath ${with pkgs; lib.makeLibraryPath [libGL libxkbcommon wayland vulkan-loader vulkan-headers]}/lib $out/bin/oblichey-cli
'';
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
}
My system flake.nix :
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
oblichey.url = "git+file:///home/simon/GIT/Rust/oblichey";
...
};
outputs = {
nixpkgs,
hyprland,
...
} @ inputs: {
nixosConfigurations = {
"TuxedoInfinityBook14Gen8" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs.inputs = inputs;
modules = [./nixos/machines/TuxedoInfinityBook14Gen8/system.nix];
};
...
};
};
}
./nixos/machines/TuxedoInfinityBook14Gen8/system.nix :
{
config,
lib,
pkgs,
modulesPath,
inputs,
...
}: {
imports = [
../../system.nix
(modulesPath + "/installer/scan/not-detected.nix")
inputs.oblichey.nixosModules.default
...
];
programs.oblichey = {
enable = true;
settings = {
camera = {
path = "/dev/video2";
};
};
};
...
}
| 08:14:25 |
Šimon Brandner | Let me know if this will do | 08:14:40 |
Šimon Brandner | Otherwise I can push some stuff to GitHub | 08:15:00 |
Šimon Brandner | (or add a file here if I forgot something...) | 08:15:30 |
blitz | Do you have module.nix as well? | 08:18:27 |
Šimon Brandner | Sure | 08:18:35 |
Šimon Brandner | {
lib,
config,
pkgs,
...
}: let
cfg = config.programs.oblichey;
in
with lib; {
options.programs.oblichey = {
enable = mkEnableOption "oblichey";
package = mkOption {
type = types.package;
default = pkgs.callPackage ./package.nix {};
description = ''
The oblichey package to use.
'';
};
settings = {
camera = {
path = mkOption {
type = types.str;
description = "Path to the IR camera to be used.";
};
};
};
};
config = mkIf cfg.enable {
environment.etc."oblichey.toml".text = ''
[camera]
path=${cfg.settings.camera.path}
'';
};
}
| 08:19:17 |
blitz | In module.nix you do pkgs.callPackage to build your program. This pkgs is the one where you use the module. I assume this is where your problem comes from | 08:20:30 |
blitz | The quick fix would be in your NixOS config to manually set the package option of this module to the package output of the flake | 08:21:31 |
blitz | This is a pretty common issue with flakes and modules. | 08:21:56 |
samasaur | I think the real fix is running nix flake lock --update-input nixpkgs in your nixos config | 08:22:10 |
blitz | But it 'works as designed' | 08:22:11 |
blitz | Or that :) | 08:22:19 |
Šimon Brandner | Not sure I follow - I would think this would be the pkgs specified in the flake.lock of the app's flake... | 08:23:04 |
Šimon Brandner | In reply to @samasaur:matrix.org I think the real fix is running nix flake lock --update-input nixpkgs in your nixos config (I am blocked by a few things 😅) | 08:23:24 |
samasaur | honestly I would have thought so too but the error you’re getting seems to be an issue with nixpkgs being out of date | 08:23:56 |
samasaur | and given that building standalone is working I am assuming the issue is with your nixos config flake | 08:24:16 |
samasaur | since idk where else nixpkgs could be coming from | 08:24:28 |
samasaur | might be something about how the module system means that it is using the nixpkgs that made the nixosSystem | 08:25:35 |
samasaur | In reply to @blitz:chat.x86.lol The quick fix would be in your NixOS config to manually set the package option of this module to the package output of the flake this is probably the right solution for your use case | 08:25:51 |
samasaur | if you can’t update the nixpkgs input of your config flake | 08:26:16 |
Šimon Brandner | Hmm, it seems to be building now | 08:29:09 |
Šimon Brandner | I would expect this to be a very common problem and I don't really understand why it works this way... | 08:29:46 |
blitz | You might want to try the NixOS discourse for these kinds of questions | 08:29:55 |
Šimon Brandner | Is there another way to use a flake in my system config? | 08:29:58 |
blitz | It's a problem with how the module is written | 08:31:40 |
Šimon Brandner | How should I write it instead? | 08:31:55 |