[Nix-dev] Import remote packages in NixOps/NixOS

Eric Sagnes eric.sagnes at gmail.com
Tue Mar 8 06:42:41 CET 2016


It is possible to import foreign modules in NixOps by doing:

```
{
  network.description = "Web server";

  webserver = { config, pkgs, ... }:
    let
      myModuleSrc = (import <nixpkgs> {}).fetchFromGitHub {
          owner  = "me";
          repo   = "myModule";
          rev    = "v1.0";
          sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
      };
    in
    { 
      imports = [ "${myModuleSrc}/module.nix" ]; 
      services.myModule.enable = true;
    };
}
```

Presupposing that the remote package provides a nix build expression,
is it possible to directly import it in a similar way?
Pseudo code that is not working:

```
{
  network.description = "Web server";

  webserver = { config, pkgs, ... }:
    let
      myPackageSrc = (import <nixpkgs> {}).fetchFromGitHub {
          owner  = "me";
          repo   = "myPackage";
          rev    = "v1.0";
          sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
      };
    in
    { 
      environment.systemPackages = [
        (import "${myPackageSrc}/release.nix")
      ];

    };
}
```

(The above complains about coercing a function to a string.)

Cheers,
-- 
Eric Sagnes
サニエ エリック


More information about the nix-dev mailing list