add flake.nix

Co-authored-by: Tobias Happ <Gerschtli@users.noreply.github.com>
This commit is contained in:
Bruno Bigras 2021-01-13 09:58:34 -05:00 committed by Alexander Sosedkin
parent abf7f56cb6
commit 9c7c0a9672
6 changed files with 61 additions and 5 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
result
result-*
out
flake.lock

View file

@ -15,6 +15,10 @@ if the `system.stateVersion` option is set to `"20.09"` or later.
either or attempt an upgrade to `release-19.09`
and follow the instructions, or backup and reinstall (preferred).
## Nix flakes support
* A `flake.nix` file was added.
## Known issues:
* If `make` fails on your device with `Function not implemented`,

View file

@ -157,7 +157,23 @@ if you are planning to maintain a long-term fork that users can update from.
In case you only care about updates through wiping the data,
you shouldn't need a binary cache for that.
## Nix flakes
Example, to use with nix flakes:
```nix
{
description = "nix-on-droid configuration";
inputs.nix-on-droid.url = "/home/bbigras/src/nix-on-droid";
outputs = { nix-on-droid, ... }: {
nix-on-droid = (nix-on-droid.lib.aarch64-linux.nix-on-droid { config = ./your_config.nix; } ).activationPackage;
};
}
```
Build with `nix build .#nix-on-droid --impure`.
## Tips

36
flake.nix Normal file
View file

@ -0,0 +1,36 @@
{
description = "Nix-enabled environment for your Android device";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, flake-utils }:
flake-utils.lib.eachSystem [
"aarch64-linux"
"i686-linux"
]
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
rec {
lib = {
nix-on-droid = { config }: import ./modules {
inherit pkgs config;
isFlake = true;
home-manager = (import home-manager { });
};
};
overlays = ./overlays;
apps.nix-on-droid = flake-utils.lib.mkApp {
drv = (pkgs.callPackage ./nix-on-droid { });
};
defaultApp = apps.nix-on-droid;
}
);
}

View file

@ -1,6 +1,6 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
{ pkgs ? import <nixpkgs> { }, home-manager ? import <home-manager> { }, config ? null }:
{ pkgs ? import <nixpkgs> { }, home-manager ? import <home-manager> { }, config ? null, isFlake ? false }:
with pkgs.lib;
@ -20,7 +20,7 @@ let
_module.args.pkgs = mkDefault pkgs;
}
configModule
] ++ import ./module-list.nix { inherit pkgs; };
] ++ import ./module-list.nix { inherit pkgs isFlake; };
};
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);

View file

@ -1,6 +1,6 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
{ pkgs }:
{ pkgs, isFlake }:
[
./build/activation.nix
@ -12,10 +12,9 @@
./environment/path.nix
./environment/session-init.nix
./home-manager.nix
./nixpkgs.nix
./time.nix
./user.nix
./version.nix
./workaround-make.nix
(pkgs.path + "/nixos/modules/misc/assertions.nix")
]
] ++ pkgs.lib.optionals (!isFlake) [ ./nixpkgs.nix ]