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

Joachim Schiele js at lastlog.de
Sun Jun 18 16:44:24 CEST 2017


see also:
https://github.com/NixOS/nixops/issues/434#issuecomment-309281751

On 09.03.2016 00:15, Eric Sagnes wrote:
> Thank you, it works perfectly with the `{}` at the end of the import!
> 
> On Tue, Mar 08, 2016 at 05:24:02PM +0100, Rok Garbas wrote:
>> 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