Skip to content

Commit ddd8164

Browse files
authored
docs: improve documentation structure and introduce templates (#195)
- Refactored README to minimize information that overlaps with the docs - Fixed DocBook documentation issues - Updated installation documentation to distinguish between NixOS and Home Manager setups - Introduced new documentation pages: - `installation_home_manager_standalone.md` for standalone Home Manager users - Added flake templates for quick setup: - `templates/nixos-module` - `templates/home-manager-nixos` - `templates/home-manager-standalone` - Minor improvements to `flake.nix`
1 parent 1c88ecc commit ddd8164

11 files changed

+754
-337
lines changed

README.md

+23-257
Original file line numberDiff line numberDiff line change
@@ -1,271 +1,37 @@
1-
> **⚠️ Important Notice: Cache Configuration Update**
2-
>
3-
> We recently migrated the `autofirma-nix` repository from one of the creators' accounts to the Nix Community's organization.
4-
> As part of this migration, the binary cache has also changed. To avoid unnecessary compilations in your local machine, please update your `flake.nix` configuration to use the new cache. Replace the `nixConfig` section in your `flake.nix` file with the following:
5-
>
6-
> ```nix
7-
> nixConfig = {
8-
> extra-substituters = [
9-
> "https://nix-community.cachix.org"
10-
> ];
11-
> extra-trusted-public-keys = [
12-
> "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
13-
> ];
14-
> };
15-
> ```
16-
>
17-
> The old cache has been be removed, so making this change promptly will ensure a seamless experience.
18-
19-
201
# autofirma-nix
212

22-
This repository provides a suite of tools needed to interact with Spain’s public administration,
23-
alongside NixOS and Home Manager modules for easy integration. These tools include:
24-
25-
- **AutoFirma** for digitally signing documents
26-
- **DNIeRemote** for using an NFC-based national ID with an Android device as an NFC reader
27-
- **Configurador FNMT-RCM** for securely requesting the personal certificate from the Spanish Royal Mint (**Fábrica Nacional de Moneda y Timbre**)
28-
29-
## Usage Example
30-
31-
```console
32-
$ nix run --accept-flake-config github:nix-community/autofirma-nix#dnieremote
33-
```
34-
35-
## AutoFirma on NixOS and Home Manager
36-
37-
A NixOS module is provided to enable AutoFirma on NixOS and another one for Home Manager.
38-
You only need to enable one of them, depending on whether you want AutoFirma
39-
system-wide or at the user level.
40-
41-
### Home Manager Configuration
42-
43-
The integration of AutoFirma in Home Manager enables the `autofirma` command for
44-
signing PDF documents and configures the Firefox browser (if enabled through
45-
`programs.firefox.enable`) to use AutoFirma on websites that require it.
46-
47-
Additionally, you can enable DNIe integration, including NFC-based DNIe from an
48-
Android mobile via DNIeRemote.
49-
50-
`autofirma-nix` provides a Home Manager module that you should import in your Home
51-
Manager configuration file. The setup may vary slightly depending on your Home
52-
Manager installation method. Below are examples for a standalone configuration.
3+
[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)
534

54-
```nix
55-
# flake.nix
5+
Nix packages, NixOS modules, and Home Manager modules for the suite of tools required to interact with Spain's public administration digital services:
566

57-
{
58-
inputs = {
59-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
- **AutoFirma** - Digital document signing and web authentication
8+
- **DNIeRemote** - Use your smartphone as an NFC reader for your Spanish national ID card
9+
- **Configurador FNMT-RCM** - Request and install certificates from the Spanish Royal Mint
6010

61-
home-manager = {
62-
url = "github:nix-community/home-manager";
63-
inputs.nixpkgs.follows = "nixpkgs";
64-
};
11+
## Quick Start
6512

66-
autofirma-nix = {
67-
url = "github:nix-community/autofirma-nix"; # If you're tracking NixOS unstable
68-
# url = "github:nix-community/autofirma-nix/release-24.11"; # If you're tracking NixOS 24.11
69-
inputs.nixpkgs.follows = "nixpkgs";
70-
};
71-
};
13+
```bash
14+
# Run DNIeRemote directly
15+
nix run github:nix-community/autofirma-nix#dnieremote
7216

73-
nixConfig = {
74-
extra-substituters = [
75-
"https://nix-community.cachix.org"
76-
];
77-
extra-trusted-public-keys = [
78-
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
79-
];
80-
};
17+
# Create a new NixOS configuration with AutoFirma
18+
nix flake new --template github:nix-community/autofirma-nix#nixos-module ./my-autofirma-system
8119

82-
outputs = {nixpkgs, home-manager, autofirma-nix, ...}: {
83-
homeConfigurations."miusuario" = home-manager.lib.homeManagerConfiguration {
84-
pkgs = nixpkgs.legacyPackages.x86_64-linux;
85-
86-
modules = [
87-
autofirma-nix.homeManagerModules.default
88-
./home.nix
89-
];
90-
};
91-
};
92-
}
93-
```
94-
95-
```nix
96-
# home.nix
97-
{ pkgs, config, ... }: {
98-
config = {
99-
programs.autofirma.enable = true;
100-
programs.autofirma.firefoxIntegration.profiles = {
101-
myprofile = { # The name of the Firefox profile where AutoFirma will be enabled
102-
enable = true;
103-
};
104-
};
105-
programs.dnieremote.enable = true;
106-
107-
programs.configuradorfnmt.enable = true;
108-
programs.configuradorfnmt.firefoxIntegration.profiles = {
109-
myprofile = { # The name of the Firefox profile where the FNMT Configurator will be enabled
110-
enable = true;
111-
};
112-
};
113-
114-
programs.firefox = {
115-
enable = true;
116-
policies = {
117-
SecurityDevices = {
118-
"OpenSC PKCS11" = "${pkgs.opensc}/lib/opensc-pkcs11.so"; # To use DNIe and other smart cards
119-
"DNIeRemote" = "${config.programs.dnieremote.finalPackage}/lib/libdnieremotepkcs11.so"; # To use DNIe via NFC from an Android mobile
120-
};
121-
};
122-
profiles.myprofile = {
123-
id = 0; # Makes this profile the default profile
124-
# ... Other configuration options for this profile
125-
};
126-
};
127-
};
128-
}
20+
# Create a new Home Manager configuration with AutoFirma
21+
nix flake new --template github:nix-community/autofirma-nix#home-manager-standalone ./my-autofirma-home
12922
```
13023

131-
### NixOS Configuration
132-
133-
The AutoFirma integration in NixOS enables the `autofirma` command for signing PDF
134-
documents and configures the Firefox browser (if enabled through
135-
`programs.firefox.enable`) to use AutoFirma on websites that require it.
24+
## Documentation
13625

137-
Additionally, you can enable DNIe integration, including NFC-based DNIe from an
138-
Android mobile via DNIeRemote.
26+
Comprehensive documentation is available at:
27+
https://nix-community.github.io/autofirma-nix/
13928

140-
```nix
141-
# flake.nix
142-
143-
{
144-
inputs = {
145-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
146-
autofirma-nix.url = "github:nix-community/autofirma-nix";
147-
# autofirma-nix.url = "github:nix-community/autofirma-nix/release-24.11"; # If you're using NixOS 24.11
148-
};
149-
150-
outputs = { self, nixpkgs, autofirma-nix, ... }: {
151-
nixosConfigurations."hostname" = nixpkgs.lib.nixosSystem {
152-
system = "x86_64-linux";
153-
modules = [
154-
autofirma-nix.nixosModules.default
155-
({ pkgs, config, ... }: {
156-
programs.autofirma.enable = true;
157-
programs.autofirma.firefoxIntegration.enable = true; # Let Firefox use AutoFirma
158-
159-
programs.dnieremote.enable = true;
160-
161-
programs.configuradorfnmt.enable = true;
162-
programs.configuradorfnmt.firefoxIntegration.enable = true; # Let Firefox use the FNMT Configurator
163-
164-
# Firefox
165-
programs.firefox.enable = true;
166-
programs.firefox.policies = {
167-
SecurityDevices = {
168-
"OpenSC PKCS#11" = "${pkgs.opensc}/lib/opensc-pkcs11.so"; # To use DNIe and other smart cards
169-
"DNIeRemote" = "${config.programs.dnieremote.finalPackage}/lib/libdnieremotepkcs11.so"; # To use DNIe via NFC from an Android mobile
170-
};
171-
};
172-
})
173-
];
174-
};
175-
};
176-
}
177-
```
29+
There you'll find:
30+
- Detailed installation instructions for NixOS and Home Manager
31+
- Configuration options reference
32+
- Security considerations
33+
- Troubleshooting guide
17834

179-
## Managing Certificates in **autofirma-nix**
35+
## License
18036

181-
The Government publishes a list of authorized service providers, each offering various
182-
certificates (production, development, valid, expired, etc.). For **autofirma-nix** to
183-
trust a specific certificate, two conditions must be met:
184-
185-
1. It must come from one of these official providers.
186-
2. It must also appear in the system’s *ca-bundle* (or *cacerts*) on NixOS.
187-
188-
This way, **autofirma-nix** only accepts certificates recognized by both the Government
189-
and the system. If the user blocks or adds one in the NixOS configuration, those changes
190-
are automatically applied to **autofirma-nix**. If a certificate is not in the local
191-
*ca-bundle*, even if an official provider publishes it, **autofirma-nix** will not include
192-
it.
193-
194-
### Relevant NixOS Options
195-
196-
The following NixOS options determine which certificates are accepted or blocked in the
197-
system *truststore*, directly affecting **autofirma-nix**:
198-
199-
- **`security.pki.certificateFiles`**
200-
Adds additional certificates to the global *truststore*. If any match the official list,
201-
**autofirma-nix** will accept them.
202-
203-
- **`security.pki.caCertificateBlacklist`**
204-
Blocks specific certificates. Even if they are on the official list, **autofirma-nix** will
205-
exclude them if they appear in this blacklist.
206-
207-
**Minimal Example**:
208-
```nix
209-
{
210-
security.pki = {
211-
certificateFiles = [
212-
./my-certificate.crt
213-
];
214-
caCertificateBlacklist = [
215-
"Izenpe.com"
216-
];
217-
};
218-
programs.autofirma.enable = true;
219-
}
220-
```
221-
222-
If `./my-certificate.crt` is on the official list, it will be included in autofirma-nix.
223-
However, since `Izenpe.com` is blocked, it will be ignored even if it appears on the
224-
official list.
225-
226-
## Troubleshooting
227-
228-
### Security devices do not seem to update or do not appear
229-
230-
If you have installed AutoFirma and enabled Firefox integration, but Firefox does not
231-
detect the security devices, you may need to remove the `pkcs11.txt` file from the
232-
Firefox profile folder. For instance, if you enabled the Home Manager module and the
233-
profile is named `myprofile`, the file is located in `~/.mozilla/firefox/myprofile/pkcs11.txt`.
234-
235-
Removing it and restarting Firefox should solve the issue:
236-
237-
```console
238-
$ rm ~/.mozilla/firefox/myprofile/pkcs11.txt
239-
$ firefox
240-
```
241-
242-
### Missing certificates even though the DNIe PIN was requested
243-
244-
If OpenSC PKCS#11 prompts you for a password but no certificates are available for
245-
signing, you might see something like the following in the Autofirma logs (when
246-
running it from a terminal):
247-
248-
```console
249-
$ autofirma
250-
...
251-
INFO: El almacen externo 'OpenSC PKCS#11' ha podido inicializarse, se anadiran sus entradas y se detiene la carga del resto de almacenes
252-
...
253-
INFO: Se ocultara el certificado por no estar vigente: java.security.cert.CertificateExpiredException: NotAfter: Sat Oct 26 15:03:27 GMT 2024
254-
...
255-
INFO: Se ocultara el certificado por no estar vigente: java.security.cert.CertificateExpiredException: NotAfter: Sat Oct 26 15:03:27 GMT 2024
256-
...
257-
SEVERE: Se genero un error en el dialogo de seleccion de certificados: java.lang.reflect.InvocationTargetException
258-
....
259-
SEVERE: El almacen no contiene ningun certificado que se pueda usar para firmar: es.gob.afirma.keystores.AOCertificatesNotFoundException: No se han encontrado certificados validos en el almacen
260-
```
261-
262-
This occurs because your certificates have expired, as indicated by the “NotAfter:” date.
263-
264-
If the certificates are not expired because you recently renewed them, but you used
265-
AutoFirma before this renewal, it is possible that OpenSC has cached your old certificates.
266-
To fix this, you need to delete the OpenSC cache. [By default, it is located at
267-
$HOME/.cache/opensc](https://github.com/OpenSC/OpenSC/wiki/Environment-variables).
268-
269-
```console
270-
$ rm -rf $HOME/.cache/opensc
271-
```
37+
This project is licensed under the MIT License - see the LICENSE file for details.

docs/src/SUMMARY.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
- [Installation](./installation.md)
66
- [NixOS module](./installation_nixos_module.md)
7-
- [Home Manager module](./installation_home_manager_module.md)
7+
- [Home Manager with NixOS](./installation_home_manager_module.md)
8+
- [Home Manager standalone](./installation_home_manager_standalone.md)
89
- [Security](./security.md)
910
- [Troubleshooting](./troubleshooting.md)
1011

docs/src/installation.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
# Installation
22

3-
This project is distributed as a Nix flake for easy integration into your NixOS configuration. It provides both a NixOS module for system-wide configurations and a Home Manager module for user-specific setups. Depending on your preference, you can choose one or the other.
3+
This project is distributed as a Nix flake that supports three integration paths:
44

5-
Keep in mind that you should enable either the NixOS module or the Home Manager module—not both simultaneously. Think of it like wearing one hat at a time.
5+
1. **NixOS module** - For system-wide installation
6+
2. **Home Manager module with NixOS** - For per-user installation when Home Manager is used as a NixOS module
7+
3. **Home Manager standalone** - For per-user installation with standalone Home Manager
68

7-
Depending on your Nix channel:
9+
## Flake Input Setup
810

9-
- Use the main branch with `nixpkgs-unstable`.
10-
- For stable channels, use the `release-XX.YY` branch corresponding to your NixOS version.
11-
12-
We officially support current releases. If you encounter issues on an older branch, upgrading is recommended, as it might resolve the problem—and let’s face it, newer is usually better.
13-
14-
Here’s an example configuration to include `autofirma-nix` as an input:
11+
For all installation methods, you'll need to add autofirma-nix to your flake inputs:
1512

1613
```nix
1714
{
1815
inputs = {
1916
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
17+
18+
# Only needed for Home Manager options
19+
home-manager = {
20+
url = "github:nix-community/home-manager";
21+
inputs.nixpkgs.follows = "nixpkgs";
22+
};
2023
2124
autofirma-nix = {
2225
url = "github:nix-community/autofirma-nix"; # For nixpkgs-unstable
@@ -33,7 +36,7 @@ Here’s an example configuration to include `autofirma-nix` as an input:
3336
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
3437
];
3538
};
36-
37-
# Further configuration details are provided in the sections below.
3839
}
3940
```
41+
42+
The binary cache configuration is strongly recommended to avoid unnecessary local compilation.

0 commit comments

Comments
 (0)