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

Rok Garbas rok at garbas.si
Tue Mar 8 17:24:02 CET 2016


Hi,

On Tue, Mar 8, 2016 at 6:42 AM, Eric Sagnes <eric.sagnes at gmail.com> wrote:
> 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.)
>


you can also just use builtins.fetchFromTarball.

for above you probably will want to do

  (import "${myPackagesSrc}/release.nix" { ... })


-- 
Rok Garbas - https://.garbas.si


More information about the nix-dev mailing list