I have a file called advancedsettings.yml that I need to place in /home/kodi/.kodi/
I’m using nixos-rebuild on a Pi.
How can I declare this file and its contents, so that it ends up there;)?
I have a file called advancedsettings.yml that I need to place in /home/kodi/.kodi/
I’m using nixos-rebuild on a Pi.
How can I declare this file and its contents, so that it ends up there;)?
Since the whole flake (and with it, your config file) gets copied to the Nix store, you can probably just use either home-manager or systemd tmpfiles to create a symlink to that config in the destination of choice. For the former, you’d use something like home.file.".kodi/advancedsettings.yml".source = "${self}/advancedsettings.yml"
and for tmpfiles check systemd.tmpfiles
options in the doc, I currently don’t have an exmaple ready.
I’m getting that “self” is undefined. I can use it configuration.nix which is included in flake.nix?
I assume that you are missing something like specialArgs = { inherit self; };
from your nixosSystem
definition. Maybe you can post your code somewhere in case this is still not fixing it.
~/repoman/2024-01-31.raspberrypi-nixos-example/flake.nix
1 {
2 inputs = {
3 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
4 nixos-hardware.url = "github:nixos/nixos-hardware";
5 };
6 outputs = { self, nixpkgs, nixos-hardware }: rec {
7 images = { 8 pi = (self.nixosConfigurations.pi.extendModules { 9 modules = [
10 "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" 11 { 12 disabledModules = [ "profiles/base.nix" ];
13 } 14 ]; 15 }).config.system.build.sdImage;
16 }; 17
18 sdImage.compressImage = false;
19
20 packages.x86_64-linux.pi-image = images.pi;
21 packages.aarch64-linux.pi-image = images.pi;
22 nixosConfigurations = {
23 pi = nixpkgs.lib.nixosSystem {
24 system = "aarch64-linux";
25 modules = [
26 nixos-hardware.nixosModules.raspberry-pi-4
27 "${nixpkgs}/nixos/modules/profiles/minimal.nix"
28 ./configuration.nix
29 ./hydra.xorg.lightdm.kodi.nix
30 ./base.nix
31 ./user.nix
32 ./home-manager.nix
33 ];
34 specialArgs = { inherit self; };
35 };
36 };
37 };
38 }
39
~/repoman/2024-01-31.raspberrypi-nixos-example/configuration.nix
1 { pkgs, config, lib, ... }:
2 {
3 environment.systemPackages = with pkgs; [
4 emacs vim git duf
5
6 #fuser, etc
7 psmisc 8 ]; 9 services.openssh.enable = true;
10 networking.hostName = "pi"; 11 users = { 12 users.b0ef = {
13 password = "root"; 14 isNormalUser = true; 15 extraGroups = [ "wheel" ];
16 }; 17 };
18
19 networking.firewall.allowedTCPPorts = [ 8085 ];
20
21 system.stateVersion = "23.11";
22
23 networking = {
24 interfaces."wlan0".useDHCP = true;
25 wireless = {
26 interfaces = [ "wlan0" ];
27 enable = true;
28 networks = {
29 shaolin.psk = "It's a secret; never teach the Wu-Tang";
30 };
31 };
32 };
33 }
~/repoman/2024-01-31.raspberrypi-nixos-example/home-manager.nix
1 { config, pkgs, ... }:
2 let
3 home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";
4 in
5 {
6 imports = [
7 (import "${home-manager}/nixos") 8 ]; 9
10 home-manager.users.kodi = { 11 home.stateVersion = "23.11"; 12
13 home.file.".kodi/userdata/advancedsettings.xml".source = "${self}/advancedsettings.xml"; 14 /* home.packages = [ pkgs.foo ]; */ 15 };
16 }
Modify the argument list of home-manager.nix
to include self
, i.e., in line 1:
{ config, pkgs, self, ... }:
That’s just excellent;). Thanks