Skip to content

How to add a custom module when using disnixos + nixops? #7

@ibizaman

Description

@ibizaman

Hi!

I want to make some changes to the postgresql-database.in module. I figured the easiest would be to copy it, modify it, and ship it with another name so dysnomia could see the new module. But I fail to do that in at least two ways:

  1. All the @var@ variables do not get substituted correctly (especially the #!/bin/bash at the top).
  2. I don't think dysnomia sees the module I copied over using nixops

I can share my full config if needed but here are the relevant parts:

In network.nix:

{
  myserver = { pkgs, ... }:
    let
      dysnomiaExtraModulePath = "dysnomia-modules";
    in
    rec {
      dysnomia = {
        enable = true;
        enableLegacyModules = false;
        extraModulePaths = ["/etc/${dysnomiaExtraModulePath}"];
      };

      environment.etc = {
        "${dysnomiaExtraModulePath}/postgresql-database-secret" = {
          source = ./dysnomia-modules/postgresql-database-secret.in;
          # mode = "0777";
        };
      };
    };
}

For the purpose of this issue, there's no need to show the specific changes to the dysnomia module I made, the issue is relevant with a verbatim copy of any module.

Issue about replacing shebang and variables

Afterwards I deploy using nixops:

$ nixops deploy -d vboxtest

And can see the file but none of the variables were replaced (which makes sense):

$ nixops ssh myserver
$ head /etc/dysnomia-modules/postgresql-database-secret -n 1
#!/bin/bash

Looking at an official module, the shebang gets replaced correctly:

$ nixops ssh myserver
$ head /nix/store/9d7jhh7xsyyx933blk0c504qff609qkl-dysnomia-0.10.1/libexec/dysnomia/postgresql-database -n 1
#!/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin/bash

I'm guessing I'm missing some call to one of the substitute* functions but I tried to grep in your repos and I don't see where that happens.

Issue about not finding module

The second issue comes from not being able to locate the module. At least that's what it looks like but I know the bash error messages can be cryptic and can hide a permission issue as something else for example.

Anyway, deploying returns this error:

$ disnixos-env -s services.nix -n network.nix -d distribution.nix --use-nixops
[...]
[coordinator]: Executing activation of services:
[target: myserver]: Activating service with key: 6c7779e925f58420b6761b4b04b8ada3412f8fcc8071ea2bc823dd943d5f6544 and package: /nix/store/47l1mkclinkqwfwgwd9r1i95vk1msrfy-ttrss with module: postgresql-database-secret in container: postgresql-database-secret, arguments: 
env: ‘/etc/dysnomia-modules/postgresql-database-secret’: No such file or directory
[target: arsenic]: Activation failed of service: 6c7779e925f58420b6761b4b04b8ada3412f8fcc8071ea2bc823dd943d5f6544
[...]

Although it looks like it should be able to find the module correctly:

$ nixops ssh myserver
$ echo $DYSNOMIA_MODULES_PATH 
/etc/dysnomia-modules:/etc/dysnomia/modules

I grepped github for any clue on how to create a new module but couldn't find anything useful. Can you give me pointers on how to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions