Skip to content

Commit

Permalink
testing-base: add home-manager vm. (#41)
Browse files Browse the repository at this point in the history
* testing-base: add home-manager vm.

* testing-base: comment out example flatpaks.

* testing-base: remove TODO item.
  • Loading branch information
gmodena authored Feb 12, 2024
1 parent e1e0d27 commit 8d8da0b
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 18 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Using flake, installing `nix-flatpak` as a NixOs module would look something lik
```

See [flake.nix](https://github.com/gmodena/nix-flatpak/blob/main/testing-base/flake.nix) in [testing-base](https://github.com/gmodena/nix-flatpak/tree/main/testing-base) for examples of setting up `nix-flatpak` as a NixOs and HomeManager module.

## Notes on HomeManager
Depending on how config and inputs are derived `homeManagerModules` import can be flaky. Here's an example of how `homeManagerModules` is imported on my nixos systems config in [modules/home-manager/desktop/nixos/default.nix](https://github.com/gmodena/config/blob/5b3c1ce979881700f9f5ead88f2827f06143512f/modules/home-manager/desktop/nixos/default.nix#L17). `flake-inputs` is a special extra arg set in the repo `flake.nix`
[mkNixosConfiguration](https://github.com/gmodena/config/blob/5b3c1ce979881700f9f5ead88f2827f06143512f/flake.nix#L29).

Expand Down
19 changes: 17 additions & 2 deletions testing-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@

A base GDM + Gnome `nixos` system to experiment with `nix-flatpak`.

## Getting started
Build a qemu virtual machine with
```bash
nix build .#nixosConfigurations.test-system-module.config.system.build.vm
```

start the system with
or
```bash
nix build .#nixosConfigurations.test-hm-module.config.system.build.vm
```

To setup `nix-flatpak` as a nixos or HomeManager module respectively.


Start the vm with
```bash
export QEMU_NET_OPTS="hostfwd=tcp::2221-:22"
result/bin/run-nixos-vm
```

and ssh into the vm with
## Login

Cerentials:
- username: `antani`
- password: `changeme`

Login via GDM or ssh into the vm with
```bash
ssh -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no antani@localhost -p 2221
```
4 changes: 2 additions & 2 deletions testing-base/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
memorySize = 1024; # Use 1024MiB memory.
cores = 2;
graphics = true; # Boot the vm in a window.
diskSize = 1000; # Virtual machine disk size in MB.
diskSize = 15000; # Virtual machine disk size in MB.
};
};

Expand All @@ -28,7 +28,7 @@
vim
];
services.xserver.enable = true;

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
Expand Down
8 changes: 1 addition & 7 deletions testing-base/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
{ config, lib, pkgs, ... }: {
imports = [
./common.nix
];
# nix-flatpak setup
services.flatpak.enable = true;
services.flatpak.update.auto.enable = false;
services.flatpak.uninstallUnmanagedPackages = true;
services.flatpak.packages = [
# ...
./flatpak.nix
];
}
34 changes: 28 additions & 6 deletions testing-base/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion testing-base/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager.url = "github:nix-community/home-manager/release-23.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
flatpaks.url = "../";
};
outputs = inputs@{ self, nixpkgs, flatpaks, ... }:
outputs = inputs@{ self, nixpkgs, home-manager, flatpaks, ... }:
let
system = "x86_64-linux";
in
Expand All @@ -17,5 +19,24 @@
./configuration.nix
];
};

# hostname = test-hm-module
nixosConfigurations.test-hm-module = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./common.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs.flake-inputs = inputs;
home-manager.users."antani".imports = [
flatpaks.homeManagerModules.nix-flatpak
./flatpak.nix
];
home-manager.users.antani.home.stateVersion = "23.11";
}
];
};
};
}
20 changes: 20 additions & 0 deletions testing-base/flatpak.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# home.nix
{ lib, ... }: {

# nix-flatpak setup
services.flatpak.enable = true;

services.flatpak.remotes = lib.mkOptionDefault [{
name = "flathub-beta";
location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo";
}];

services.flatpak.update.auto.enable = false;
services.flatpak.uninstallUnmanagedPackages = true;
services.flatpak.packages = [
#{ appId = "com.brave.Browser"; origin = "flathub"; }
#"com.obsproject.Studio"
#"im.riot.Riot"
];

}

0 comments on commit 8d8da0b

Please sign in to comment.