diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0ba04..7731311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ Changes yet to be released are documented here. - Fix path expansion when running in systemd -- Fix bug in netrc writing - Add nixos, home-manager, and darwin-nix modules ## v0.1.0 diff --git a/home-module.nix b/home-module.nix index 572366e..90e80ab 100644 --- a/home-module.nix +++ b/home-module.nix @@ -26,7 +26,6 @@ in }; config = lib.mkIf cfg.enable { - nix.settings.netrc-file = "${config.xdg.configHome}/nix/netrc"; home.packages = [ cfg.package ]; systemd.user.services.nix-cache-login = { Unit.Description = "Nix cache login - refresh access token"; diff --git a/internal/netrc/netrc.go b/internal/netrc/netrc.go index 6eaae73..f020a4d 100644 --- a/internal/netrc/netrc.go +++ b/internal/netrc/netrc.go @@ -25,7 +25,7 @@ func Upsert(path, machine, password string) error { } } if !found { - entries = append(entries, entry{machine: machine, login: "dummy", password: password}) + entries = append(entries, entry{machine: machine, password: password}) } return write(path, entries) @@ -71,7 +71,6 @@ func GetPassword(path, machine string) (string, error) { type entry struct { machine string - login string password string } @@ -103,10 +102,6 @@ func parse(path string) ([]entry, error) { entries = append(entries, *current) } current = &entry{machine: fields[1]} - case "login": - if current != nil { - current.login = fields[1] - } case "password": if current != nil { current.password = fields[1] @@ -134,7 +129,7 @@ func write(path string, entries []entry) error { if i > 0 { b.WriteString("\n") } - fmt.Fprintf(&b, "machine %s\nlogin %s\npassword %s\n", e.machine, e.login, e.password) + fmt.Fprintf(&b, "machine %s\npassword %s\n", e.machine, e.password) } if err := os.WriteFile(path, []byte(b.String()), 0600); err != nil { diff --git a/internal/netrc/netrc_test.go b/internal/netrc/netrc_test.go index e8a0b51..611c8c4 100644 --- a/internal/netrc/netrc_test.go +++ b/internal/netrc/netrc_test.go @@ -27,7 +27,7 @@ func TestUpsertUpdateExisting(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "netrc") - initial := "machine other.host\nlogin dummy\npassword otherpass\n\nmachine cache.example.com\nlogin dummy\npassword oldtoken\n" + initial := "machine other.host\npassword otherpass\n\nmachine cache.example.com\npassword oldtoken\n" if err := os.WriteFile(path, []byte(initial), 0600); err != nil { t.Fatal(err) } @@ -59,7 +59,7 @@ func TestUpsertAppend(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "netrc") - initial := "machine existing.host\nlogin dummy\npassword existingpass\n" + initial := "machine existing.host\npassword existingpass\n" if err := os.WriteFile(path, []byte(initial), 0600); err != nil { t.Fatal(err) } @@ -89,7 +89,7 @@ func TestRemove(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "netrc") - initial := "machine keep.host\nlogin dummy\npassword keeppass\n\nmachine remove.host\nlogin dummy\npassword removepass\n" + initial := "machine keep.host\npassword keeppass\n\nmachine remove.host\npassword removepass\n" if err := os.WriteFile(path, []byte(initial), 0600); err != nil { t.Fatal(err) } @@ -141,7 +141,7 @@ func TestGetPasswordNotFound(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "netrc") - content := "machine other.host\nlogin dummy\npassword otherpass\n" + content := "machine other.host\npassword otherpass\n" if err := os.WriteFile(path, []byte(content), 0600); err != nil { t.Fatal(err) } @@ -179,7 +179,7 @@ func TestFilePermissionsCorrected(t *testing.T) { path := filepath.Join(dir, "netrc") // Create file with overly permissive mode - if err := os.WriteFile(path, []byte("machine old.host\nlogin dummy\npassword oldpass\n"), 0644); err != nil { + if err := os.WriteFile(path, []byte("machine old.host\npassword oldpass\n"), 0644); err != nil { t.Fatal(err) }