I’m trying to mount a samba share, as described here, but I can’t find any evidence that NixOS is even attempting to mount the share.
I’m building and running a VM with these commands, the flake.nix and configuration.nix are below:
$ nix build \
.#nixosConfigurations.test.config.system.build.vm \
--extra-experimental-features "nix-command flakes pipe-operators" \
--impure
$ ./result/bin/run-nixos-vm
$ ssh admin@localhost -p 2222 # password is "password"
When I build and run, I can’t see anything:
-
From
systemctl list-units | grep buffalo(or grepping for e.g.media) -
From
journalctl -b | grep buffalo(and grepping forcifsshows the kernel inserted thecifsmodule, at least) -
Anything in
/etc/fstab(thought these were supposed to be done as systemd services but thought I should check just in case!)
I’m pretty new to NixOS so I’m aware I maybe doing something silly but I can’t find why the below isn’t getting through to the image on the VM, any help is very much appreciated!
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, home-manager, ... }@attrs:
let
system = "x86_64-linux";
in
{
# test is a hostname for our machine
nixosConfigurations.test = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
home-manager.nixosModules.home-manager
./configuration.nix
];
};
};
}
# configuration.nix
{ lib, config, pkgs, ... }:
{
system.stateVersion = "26.05";
#
# Things I think I need to get Samba to work.
#
# Basic packages available inside VM
environment.systemPackages = [
pkgs.cifs-utils
pkgs.samba
];
systemd.tmpfiles.rules = [
"d /media/buffalo 0777 root root -"
];
fileSystems = {
"/media/buffalo" = {
device = "//123.45.2.1/buffalo";
fsType = "cifs";
# TODO: credentials=/etc/buffalo.TODO,
#options = ["rw,vers=2.0,file_mode=0777,dir_mode=0777"];
options = [
"rw"
"vers=2.0"
#"credentials=/etc/buffalo.credentials" # Or whatever you name the file
"file_mode=0777"
"dir_mode=0777"
"_netdev" # CRITICAL: Wait for network
"nofail" # CRITICAL: Don't block boot
"guest"
];
};
};
#
# Extra config so you can `ssh admin@localhost -p 2222` (password
# "password") to a sudo-capable user.
#
virtualisation.forwardPorts = [
{ from = "host"; host.port = 2222; guest.port = 22; }
];
# Allow passwordless sudo (optional)
security.sudo = {
enable = true;
wheelNeedsPassword = false;
};
# Graphics in the VM (optional)
virtualisation.graphics = true;
services.openssh.enable = true;
# Optional but recommended:
services.openssh.settings = {
PermitRootLogin = "no";
PasswordAuthentication = true;
KbdInteractiveAuthentication = false;
};
boot.kernelModules = [ "cifs" ];
boot.supportedFilesystems = [ "cifs" ];
users.users = {
admin = {
isNormalUser = true;
password = "password";
extraGroups = [ "wheel" ];
};
};
}